in reply to capture vars undef

From perldoc perlre:

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.

So, in your case, I think inner $<digit> vars go out of scope, getting undef