Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: regex match with interpolated pattern

by fletcher_the_dog (Friar)
on Aug 18, 2004 at 19:49 UTC ( #384089=note: print w/replies, xml ) Need Help??


in reply to Re: regex match with interpolated pattern
in thread regex match with interpolated pattern

You're date variable is using / as the delimiter. As a result you aren't matching the pattern you think you are. You could just use a different delimiter for your pattern.
if ($_ = m%$dm%) { #stuff }
If you are interpolating a string it does not matter if it has characters that are the same as the delimiter. The boundaries of the regex are determined before the interpolation is done. Try this:
perl -e '$string = "/"; print "08/14/04"=~/$string/ ? "matched\n" : "no match\n"'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2021-09-22 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?