Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Turning an argument into a regexp

by ncw (Friar)
on Aug 31, 2000 at 01:16 UTC ( [id://30408]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-26 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found