Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Turning an argument into a regexp

by le (Friar)
on Aug 30, 2000 at 22:04 UTC ( #30361=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://30361]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2022-11-30 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?