To open a text file and check for every element in an array within the file:
- open the file
- read it into an array
- close the file
- for each element of the file_array, grep for each element of the targets_array
You'll need to understand map and grep to get this:
#!/usr/bin/perl -w
# look for elements of array @targets in file $file
use strict;
my @targets=qw|target1 target2 target3|;
my $file = 'myfile';
open (INPUT, $file);
my @file_lines = <INPUT>;
close INPUT;
my @found_lines = map { my $tg=$_;
grep {/$tg/x} @targets } @file_lines ;
print join ", ",@found_lines;
print "\n";
HTH
Charlie
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com