foreach $output (@output) { if ($output =~ /$str_to_find/) { print "$output\n"; } }