When running this snippet, I expected that, since $1 “looks” like a
global variables, it would be propagated across method calls. Should it
be?
From the pickaxe, Variables and Constants:
$1 to $9
String
The contents of successive groups matched in a successful pattern match.
In “cat” =~/(c|a)(t|z)/, $1 will be set to a and $2 to t. THIS VARIABLE
IS LOCAL TO THE CURRENT SCOPE. [r/o, thread]
The contents of successive groups matched in a successful pattern match.
In “cat” =~/(c|a)(t|z)/, $1 will be set to a and $2 to t. THIS VARIABLE
IS LOCAL TO THE CURRENT SCOPE. [r/o, thread]
Personally I love the Perl heritage stuff like this. But for someone
coming
from a non-Perl background, damn that must seem pretty weird and
surprising.