my $searchstring= '\Q' . join('\E|\Q',@output). '\E'; while (my $line=) { if ($line=~/$searchstring/) { print $line; } }