It *is* optimized away (according to Deparse), but not before satisfying our needs. The safe version would be:
{ use warnings; my $thingy = 'thangy'; sub doit { no warnings 'void'; $thingy; # Close over $thingy eval 'print "thingy is $thingy\n"'; } } doit(); # "thingy is thangy"
In reply to Re^6: "eval" and "my" variable weirdness
by ikegami
in thread "eval" and "my" variable weirdness
by splinky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |