in reply to USE, but fail nicely
The eval {}; form actually tokenizes what is inside the brackets and thus the parser will catch use, no, BEGIN {}, and END{} pragmas and blocks. The string form is just a string till the eval actually happens at runtime.
Try these at the commandline to see the various behaviors:
perl -e 'if(shift){eval{BEGIN{print"eek\n"}print"ahh\n"}}' 0 perl -e 'if(shift){eval{BEGIN{print"eek\n"}print"ahh\n"}}' 1 perl -e 'if(shift){eval"BEGIN{print\"eek\n\"}print\"ahh\n\""}' 0 perl -e 'if(shift){eval"BEGIN{print\"eek\n\"}print\"ahh\n\""}' 1
--
$you = new YOU;
honk() if $you->love(perl)
|
|---|