extract words from txt using perl

Hi,
i will deal with txt file and i want to use perl to extract number of words from this txt
ex :if the txt file is a story which contains person names and iwant to extract these names and there is something else that these names which i want perl to extract must match the words (person names)
wich are saved in a mysql database.
now i need perl to deal with database get person names from its first column and compare it word by word with the txt file words till it find all the matches using perl.
The output should be txt file contains the person names that match the database words and already exist in the txt file. unfortunately i am beginner in this language and i don't know how to deal with this problem.

If you are a beginner, then the problem, in its entirety, may look daunting. Break it up into small pieces and work on them individually.

(1) First, connect to the MySQL database from Perl using DBI.
(2) Run the query and store the results - either in a file or better still, in a hash (if memory isn't an issue or if there aren't too many words).
(3) Next, open the text file and loop through each word.
(4) Check if the word is a hash key. If it is, print the word to stdout or to a file.

Hope these suggestions will at least get you started.

tyler_durden

Thanks very much now the task begin to be easy but sorry i will have questions while i am going ahead with that.( as really it is the first time for me to use perl)

About the connection with mysql this is the perl function as i wrote it in a notebad and saved it begin.pl and i went to command prompt and i wrote

C:\Perl\eg\begin.pl

the code in the begin.pl is

 
#!/usr/bin/perl
BEGIN {
# PERL MODULES WE WILL BE USING
use DBI;
use DBD::mysql;
$dbh = DBI->connect('DBI:mysql:db1', 'person') || die "Could not connect to database: $DBI::errstr";}
# (insert query examples here...)
$sth = $dbh->prepare('SELECT describtion FROM protein_names where gene_name=AMELY');
$sth->execute();
$result = $sth->fetchrow_hashref();
print "Value returned: $result->{description}\n";
 
end{
$dbh->disconnect();
}

but the code don't work and when i type the path

C:\Perl\eg\begin.pl in the command prompt the answer is :
is not recognized as internal or external command

Note: i made sure that the perl has the modules which i used above