Hi,
Now i work in a code that
1-get data stored in the database in the form of hash table with a key
field which is the " Name"
2-in the same time i open a txt file and loop through it word by word
3- which i have a problem in is that :
I need to loop word by word and check if it is a hash key or not if a hash key print it .
#!/usr/bin/perl
use DBI;
$sqlstatement= "select Name from Protein;";
#open connection to Access database
$dbh = DBI->connect('dbi:ODBC:driver=microsoft access driver (*.mdb);dbq=C:\Perl\eg\db1.mdb');
#prepare and execute SQL statement
$sth = $dbh->prepare($sqlstatement);
$sth->execute ||
die "Could not execute SQL statement ... maybe invalid?";
#output database results
while ( $ref = $sth->fetchrow_hashref($Name) )
{
print "$$ref{'Name'} \n";
}
$filename= 'C:/Perl/eg/members.txt';
open (FILE,$filename) or die $!;
while (<FILE>){
# split each input line; words are separated by whitespace
for $word (split)
{
print $word . "\n";
}
}
close (FILE);
The code now can only print the hash returned from the database
and split the txt into words.