in reply to Turning an argument into a regexp

I agree with the comments above. I'd just like to add an oft forgotten thing (obscure feature alert ;-) to do with regexps, namely \Q and \E for turning off regular expression parsing.

If $searchfor contained characters special to regexp (eg '.' or '?') then you won't get quite the results you expect, and your program may crash with an invalid regexp error. Use \Q and \E something like this...

my $MP3dir = $ARGV[0]; my $searchfor = $ARGV[1]; find(\&wanted, $MP3dir); sub wanted { /\.\Q$searchfor\E$/ or return