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]
(emphasis mine)
···
On Jun 27, 2012, at 13:26 , Roger Pack wrote:
Hello all.
When running this snippet, I expected that, since $1 "looks" like a
global variables, it would be propagated across method calls. Should it
be?
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.
···
On Wed, Jun 27, 2012 at 4:36 PM, Ryan Davis <ryand-ruby@zenspider.com>wrote:
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]