Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Bug or feature? s/// and the g option

by Belgarion (Chaplain)
on Oct 14, 2007 at 16:17 UTC ( [id://644764]=note: print w/replies, xml ) Need Help??


in reply to Re: Bug or feature? s/// and the g option
in thread Bug or feature? s/// and the g option

Interesting. So a failed match will clear the $1 variable. I'm still a little stumped by Marco's original example:
$test = <<'END'; XXWY XXWZ END $count = $test =~ s#(XXW?Y)##gi; print "REMOVED: <<$1>>\nCOUNT: $count\n";
That fails. But remove the "i" in the substitution and $1 is defined. Why would case-insensitive make any difference?
--rjk

Replies are listed 'Best First'.
Re^3: Bug or feature? s/// and the g option
by ysth (Canon) on Oct 14, 2007 at 19:46 UTC
    AIUI, without the i, before the regex engine proper is entered, there's an optimization that makes it search for an XX followed later by a Y. That optimization rejects a match, and when that happens, it bypasses the bug that's setting $1 to undef. Seems to be fixed for 5.10.0.
      Ah, thanks for the explanation ysth!
      --rjk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2026-05-13 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.