http://qs1969.pair.com?node_id=30361


in reply to Turning an argument into a regexp

I don't think the File::Find module has problems with a variable being a regexp. But you should let Perl know that you actually mean a regexp. In your example, $regex is treated as a scalar, not as a regex. Try something like this:
my $regex = "\\.$searchfor"; $file =~ m/$regex/;
Putting the regex delimiters into the variable may work with an eval, but this is just a wild guess.