in reply to Unexpected matching results
He's a shorter example:
At run time, the variable $1 is pushed on the argument stack twice, then print is called. Print evaluates each of its arguments, getting its string value, and at this point $1 evaluates to the first capture of the last pattern match.$_ = '1a'; print( (/(\d)/ ? $1 : 0), (/(\D)/ ? $1 : 0), "\n"); #aa print( (/(\d)/ ? "$1" : 0), (/(\D)/ ? "$1" : 0), "\n"); #1a
Think of $1 being tied, with FETCH() being called (twice) from print.
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unexpected matching results
by hdb (Monsignor) on Sep 06, 2013 at 07:51 UTC |