Re: Seeing if any element of an array is in the current line

2009-08-15 Thread Bryan Harris
> Hello, I'm trying to write a simple Perl script to output certain lines > from a logfile that contain any of a few phrases. [clip] > my @goodlist = ("word1", "word2"); I had some fun with this one lately. =) perl -e '@gl=qw/word1 word2/; print grep {$t = $_;grep {$t=~/$_/} @gl } <>' I ca

Re: Seeing if any element of an array is in the current line

2009-08-13 Thread Shawn H. Corey
Mazza, Glen R. wrote: 1.) (Major question) I was wondering if I could get rid of the foreach and instead use some construct like: If (/@goodlist/) {...} Meaning "if the current line has *any* of the words in the array..." See `perldoc perlfaq6` and search for /How do I efficiently match