in reply to Scoping the regex memory variables and where do I go next
Don't rely on the values of $1 et al. if you don't know that the regex matched.
Here's a very simple example:
/(a)/; print "matched $1\n"; # WRONG! if (/(a)/) { print "matched $1\n"; # Right }
|
|---|