On Fri, Apr 21, 2006 at 12:45:13PM -0500, Jonathan Scott Duff wrote: : According to S05, "a /.../ matches immediately in a value context : (void, Boolean, string, or numeric)" and since : : (state $x) ||= / pattern /; : : is very much the same as : : state $x; $x = $x || /pattern/; : : I'd say that's a "boolean context" and thus matches against $_ instead : of assigning the Regex object to $x.
Except the right side of || isn't in boolean context till you evaluate $x that way, so it probably wants to be written with m//: state $x; $x = $x || m/pattern/; to force the match immediately. Also, the emulation of ?...? is not complete without actually evaluating $x, so this might be clearer: $result = do { state $x ||= m/pattern/ } or maybe even $result = do { state $x ||= m/pattern/; $x } though of course that's redundant since the ||= returns its current value. Larry