$text="I have a problem with pre-compiled regex"; @words=qw(have regex); for $a(@words) { while ($text =~ m/$a/g) { print "Found $&\n"; } }