Dear Uri,
Thanks to you and the others for your prompt responses.
> another bad point about eval is that it can access and modify lexicals
> and globals anywhere in the code. so that can lead to action at a
> distance and very hard to find bugs.
I don't quite follow.
Globals are anyway accessible. How does eval() make things worse?
How can lexicals that are outside the scope of the eval statement be visible?
I made an I-know-I-am-not-doing-what-you-mean attempt, which failed
predictably.
----------------------\/--------BEGIN---------\/----------------------
% perl -wMwarnings -le '{my $x = 10} eval q{print $x;}; eval {print $x;}'
Name "main::x" used only once: possible typo at -e line 1.
Use of uninitialized value in print at (eval 1) line 1.
Use of uninitialized value in print at -e line 1.
%
----------------------/\---------END----------/\----------------------
So could you show me examples of "naughty" access of globals and
locals through eval()?
Your point about eval-BLOCK not being an eval at all is co-incidentally
demonstrated by the above one-liner. The warning from the eval-STRING
mentions "eval". The warning from the eval-BLOCK does not.
> send a copy of perl best practices to him and watch his eyeballs hit the
> floor when he sees how many other of damian's rules he is breaking. :)
:-)
As soon as you I read the review copy I get from you, I guess. :-)
peace, || What can one hour achieve?
--{kr.pA} || http://www.workanhour.com/
--
Kid, n.: A noise with dirt on it.
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm