in reply to Lexical variable not available

This works fine, so it seems to be how the q() is compiled.
sub { my $v = 111; eval { eval 'print $v, " x\n"'; eval 'print $v, " y\n"'; print $v, " z\n"; }; }->();

Replies are listed 'Best First'.
Re^2: Lexical variable not available
by choroba (Cardinal) on Mar 19, 2024 at 07:42 UTC
    The main difference should be when the block eval versus the string eval is compiled, not how.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^2: Lexical variable not available
by LanX (Saint) on Mar 18, 2024 at 22:06 UTC
    Two very different kinds of eval

    Without the q{} you are essentially only doing block-eval which is Perl's version of a try-catch

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