in reply to Lexical variable not available

my (wild) guess is compile-time vs run-time confusion with lex-pads.

Each sub (and block) has a so called lex-pad where all it's own and closed-over lexicals are listed¹. That's all settled at compile-time.

These evals are kind of accessing closed-over vars but at run-time.

But I doubt anyone thought about testing this with nested evals.

I suppose evals have a lex-pad too, but when exactly is it intialised?

TL;DR

I think different evals are accessing different scopes because of race conditions. Introducing {BLOCKS} and anonymous subs into the evaled code might fix this.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

¹) compare PadWalker