my @terms = qw(one two three); @matches = grep { my $line = $_; grep {$line =~ /$_/} @terms } @lines_from_file;