"slurping" in a whole file into a scalar variable sounds like a good idea in this case. $text = <IN>; looks fine to me. There is no need for @text = <IN>.
I would suggest the use of the Perl function index() rather than regex in this situation.
index requires an exact match and so you should case search term and search text to be the same. But this "casing" operation is very fast. The index function will quit on the first match which is an advantage over regex this situation.
As always, your mileage may vary! Short "how to" is shown below.
#!/usr/bin/perl -w
use strict;
my @listOfWords = qw (january
february
egypt
moon
saturday
zoos
zoo
thingies
thing
);
my $text = "moon. I love full moons but
this it has been a long thing since yesterday on the
beach. And a whole buch of BLAH.\nYet another february line.\n
More jan stuff goes here. What a zoo this text
searching thing can be!";
print"\n\nUsing ListOfWord Tokens\n";
foreach my $word (@listOfWords)
{
if ( index($text,"$word")>= 0)
{
print "word: $word\t found\n";
}
else
{
print "word: $word\t NOT found\n";
}
}
__END__
Using ListOfWord Tokens
word: january NOT found
word: february found
word: egypt NOT found
word: moon found
word: saturday NOT found
word: zoos NOT found
word: zoo found
word: thingies NOT found
word: thing found