in reply to grep for lines containg two variables
@interesting_lines = grep /$string1/, grep /$string2/, @log;
or
@interesting_lines = grep /$string1/ && /$string2/, @log;
or
@interesting_lines = grep /^(?=.*$string1)(?=.*$string2)/, @log;
OT Note: If your strings contain text, not regex, be sure to escape them using quotemeta or /\Q$string\E/. Better yet, use index instead of regexs in that case since it's much faster.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: grep for lines containg two variables
by l3v3l (Monk) on Dec 07, 2005 at 23:35 UTC | |
by ikegami (Patriarch) on Dec 08, 2005 at 01:09 UTC | |
by l3v3l (Monk) on Dec 08, 2005 at 17:54 UTC | |
by ikegami (Patriarch) on Dec 08, 2005 at 18:35 UTC | |
by l3v3l (Monk) on Dec 08, 2005 at 19:55 UTC | |
|
Re^2: grep for lines containg two variables
by tweetiepooh (Hermit) on Dec 08, 2005 at 14:12 UTC | |
by ikegami (Patriarch) on Dec 08, 2005 at 15:07 UTC | |
by tweetiepooh (Hermit) on Dec 08, 2005 at 16:27 UTC | |
by ikegami (Patriarch) on Dec 08, 2005 at 18:16 UTC |