"frederik@ugcs.caltech.edu (via RT)" <perlbug-followup@perl.org> wrote: > > sub r > { > shift =~ /(.*)/; > if(shift) { > r("bar", 0); > print "$1\n"; > } > } > r("foo", 1); > > # prints: bar > # (expected: foo) As I *know* how the digit variables are implemented, I actually expect "bar" there, but you're right, most people probably expect "foo". Basically regexp vars ($1 and alii) are associated to regexps. There's one set of such variables per regexp. In addition, there's some magic to change the "current" regexp -- the one in scope -- at scope exit. There's only one regexp in your code snippet I quoted, thus only one $1 variable slot, so it's normal that you get only one value out of $1. This could be better documented.Thread Previous