You're not going crazy.
Thank you
japhy, that's reassuring :-)
The scope of $<digit> (and $`, $&, and $') extends to the end of the enclosing BLOCK or eval string, or to the next successful pattern match, whichever comes first.
But it does not say that those vars will not be mangled by a passing-by unsuccessful match :-(
What you discovered/confirmed (
Perl LINKS the digit variables to SECTIONS of the string) should be documented in bold letters right in the perlre page where a perl newbie first meets those variables.Did you submit that bug report?
It would be good if the behavior of
$<digit> variables could be specified and implemented such that at any time they either contain the result of the last successful match or are undefined. In the meantime, I will remember not to rely on them and use the list assignment.
Rudif