in reply to Re: Using array elements for a file search
in thread Using array elements for a file search

Hi, I'm looking for something very similar. I have an array of strings, which I want to match to the end of log file entries. At first I did something similar to the original poster:
my @zones = `cat zones.txt`; chomp (@zones); open (IN, 'logfile.log'); while (<IN>) { chomp; foreach my $zone (@zones) { if ($_ =~ /$zone$/) { print "$zone match\n"; last; } } } close IN;
But obviously that's rather inefficient and takes for ever. Could your example, of joining the array to a regular expression string, be modified and used in this case where it needs to match the end of the string?