Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Improve processing time for string substitutions

by Anno (Deacon)
on Apr 16, 2007 at 15:46 UTC ( [id://610384]=note: print w/replies, xml ) Need Help??


in reply to Re: Improve processing time for string substitutions
in thread Improve processing time for string substitutions

Is there a reason for the non-capturing parens in "$re = qr/(?:$re)/;"?

What good does the /e switch do in the regex "s/($re)/$entitylist{ $1 }/ge;"?

Anno

Replies are listed 'Best First'.
Re^3: Improve processing time for string substitutions
by ikegami (Patriarch) on Apr 16, 2007 at 15:56 UTC
    No (qr// already adds non-capturing parens) and none (interpolation is done after each match).
Re^3: Improve processing time for string substitutions
by Corion (Patriarch) on Apr 16, 2007 at 15:56 UTC

    The /e switch is an error by me - it is a leftover from when I thought about doing the hex-conversion manually with a sprintf call in the right hand side..

    I always build my regular expressions with noncapturing parentheses when I pal on latter assembling them - this prevents embarassing bug hunts later when I change how the target RE is built, possibly by repeating one ("atomic") building block - leaving out the parentheses causes hard-to-track misbehaviour with input on the seam of the two blocks.

    .
      I always build my regular expressions with noncapturing parentheses when I pal on latter assembling them - this ...

      Same here, but I've always thought of qr// as an alternative way to add those parens (which it does). You are, in effect, adding two pairs.

      Anno

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found