http://www.perlmonks.org?node_id=644764


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