in reply to Curious about regex capture in conditional
$<digits>
Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. (Mnemonic: like \digits.) These variables are all read-only and dynamically scoped to the current BLOCK.
That's from perlvar, discussing the $1, $2, etc. special variables. You're just seeing evidence of the fact that those special variables are dynamically scoped to the current block. In your first test, the block ends before you get around to examining the contents of $1. When the block ends, the dynamic scope of $1 ends, and you can't see what used to be there.
Dave
|
|---|