http://www.perlmonks.org?node_id=514889


in reply to grep for lines containg two variables

@interesting_lines = grep {/$string1/ xor /$string2/} @log;
will do nicely.

Hope this helps, -gjb-

Update: apparently I got the question wrong, see the previous answer or for an alternative syntax:

@interesting_lines = grep {/$string1/ and /$string2/} @log;