in reply to Trouble with foreach loop.... I think
However, if you go through alot of records this will be slow as it has to reparse the regular expression over and over. If your regex (list of strings to match) is truely variable and you process lots of records then it might be more efficient to assemble some perl code and eval it. The advanced perl book ( the one with the panther on it ) has a good example in it in the eval chapter.my @netstat = `netstat -s`; my @matches=("invalid headers", "packets dropped"); my $matches = join('|', @matches); foreach (@netstat) { print if /$matches/; }
|
---|