in reply to memory variables (chp. 9 & 10 Learning Perl 3)
As for the difference between \1 and $1, the \1 is used within the same regex as the capturing parens, while the $1 is used outside the regex.
For example, in:
the \1 matches whatever was matched in the () within the same regex, and the $1 refers to the same matched item, but outside the regex.if (m/(\w+)\1/) { print "Found $1 twice\n"; }
Hope this clears it up a bit.
|
|---|