sub findString($) { my $line = shift; my $compiled_regex = eval "qr/$regex/"; if ($line =~ /$compiled_regex/) { print "found\n"; } }