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

Re: resetting Perl RegEx backreferences

by hv (Prior)
on Mar 08, 2006 at 20:11 UTC ( [id://535251]=note: print w/replies, xml ) Need Help??


in reply to resetting Perl RegEx backreferences

As davido says, checking that the match succeeded is almost always the right solution. If for some reason you don't want to do that, easiest way is to throw a cheap guaranteed match in before the real match:

"" =~ /(?=)/; # reset match vars $dorient =~ /^([^_]+)_/; $rs[2] = $1; # or undef if no match

Hugo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-18 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found