in reply to Re^2: trouble with packages/eval/variable-scoping
in thread trouble with packages/eval/variable-scoping
IIRC, this also works:
$gold if 0;
It doesn't modify the var. It doesn't result in any run-time code at all.
Demo:
$ perl -Mv5.10 -we \ 'do { my $x = 42; sub { say eval q{$x} } }->()' Variable "$x" is not available at (eval 1) line 1. Use of uninitialized value in say at -e line 1. $ perl -Mv5.10 -we \ 'do { my $x = 42; sub { $x if 0; say eval q{$x} } }->()' 42
Update: Tested and added demo.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: trouble with packages/eval/variable-scoping
by LanX (Saint) on Aug 29, 2024 at 16:11 UTC | |
by ikegami (Patriarch) on Aug 29, 2024 at 17:00 UTC |