Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Disabling regexp optimizations?

by diotalevi (Canon)
on Oct 15, 2005 at 18:52 UTC ( [id://500486]=note: print w/replies, xml ) Need Help??


in reply to Re: Disabling regexp optimizations?
in thread Disabling regexp optimizations?

The code in (?{...}) might have a desired side effect. Usually you use (?{...}) blocks only for their side effects because they don't normally impact whether the expression matches. In my case, I've implemented named captures and would like to pre-clear the targets just in case my capture expressions never get evaluated because something earlier failed. That is, CLEAR->stuff->CAPTURE. If "stuff" failed, then I wouldn't have had the opportunity to ensure that CAPTURE properly cleared the selected target.

Replies are listed 'Best First'.
Re^3: Disabling regexp optimizations?
by bart (Canon) on Oct 16, 2005 at 00:31 UTC
    I like your idea, but... It is not how (anonymous) captures in Perl work, do they? I mean, nothing is guaranteed about the value of $1, $2 etc. in a regexp with captures, if the regexp doesn't match.
      Of late, I'm not sure that's so true. The most recent perls (the last year anyway) ensures that all potentially used capture variables are cleared regardless of whether the expression succeeds. So /((...)|(...))/ addresses $1, $2, and $3. Since the fix, you can guarantee that each variable will have a sane value. You still can't guarantee $4 -> on though. I think. Or could those be guaranteed already?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-18 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found