Ok fellas .. first thanks for the help ... it all definitely moved me in the right direction
The question : How many times do the lines shown in Source file show up in the Result file
Source file
-----------
car
boat
house
girl
hate
Result file
----------
car
boy
girl
dog
car
love
hate
boat
boat
hate
boat
boat
boy
girl
dog
Script results :
---------------
1 lines in the result file contain: car
4 lines in the result file contain: boat
0 lines in the result file contain: house
2 lines in the result file contain: girl
2 lines in the result file contain: hate
Code - one thing I need to look at ... the break out is brutal
open (FILE1, "cv1.TXT") or die "$0: Could not open SOURCEFILE.TXT: $!\n";
open (FILE2, "cv2.TXT") or die "$0: Could not open RESULTFILE.TXT: $!\n";
chomp(my @strings = <FILE2>);
while (1) {
foreach $pattern (<FILE1>) {
chomp($pattern);
#last if $pattern =~ /^\s*$/;
my @matches = eval {
grep /$pattern/, @strings;
};
if ($@) {
print "Error: $@";
} else {
my $count = @matches;
print "$count lines in the result file contain: $pattern \n"
}
}
exit;
}