in reply to Re^4: "eval" and "my" variable weirdness
in thread "eval" and "my" variable weirdness

Your version is dangerously close to getting optimized away into nothingness. Just disable the warning. That's much safer.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

  • Comment on Re^5: "eval" and "my" variable weirdness

Replies are listed 'Best First'.
Re^6: "eval" and "my" variable weirdness
by ikegami (Patriarch) on Jun 29, 2006 at 17:32 UTC

    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"