Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Precompiling qr/.../o question

by hardburn (Abbot)
on Apr 02, 2008 at 19:11 UTC ( #678026=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Precompiling qr/.../o question
in thread Precompiling qr/.../o question

Sure, it technically works (probably because /o gets dragged along into qr// like any other regex option list), but it's still redundant and confusing.

The problem with /o is when you start with something harmless like this:

for (1 .. 5) { print "Match!\n" if $some_string =~ /very long regex/o; }

Then later you realize you need to add a loop variable to the regex:

for (1 .. 5) { print "Match!\n" if $some_string =~ /very long regex $_ more regex/o; }

Which results in the regex checking against '1' instead of the current loop var. This is almost never what you want, and has caused new and experienced programmers alike to waste many hours of debugging. That's why qr// was invented to Do the Right Thing.


"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.


Comment on Re^3: Precompiling qr/.../o question
Select or Download Code
Re^4: Precompiling qr/.../o question
by mr_mischief (Prior) on Apr 02, 2008 at 21:52 UTC
    Your wording read to me like you meant that the /o option was semantically redundant when used on the qr// itself.

    Now I realize you meant something else entirely. I think you're saying that as a feature it's been made redundant because there are better ways to accomplish that it was originally meant to do. I wouldn't disagree with that.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-04-20 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls