The documentation about the eval function mentions nothing of the sort. Clearly having compiler warnings for every instance of eval seems ridiculous, but I feel that something about this needs to be in the main documentation about the eval function.Patches welcome.
Your example is actually working with two completely different scopes. Consider this:
use temp1; use warnings; use strict; temp1::init(); use temp1; use warnings; use strict; temp1::init(); print "Calling work1: " . temp1::work1( '$var = 3' ) . "\n"; print "Calling work2: " . temp1::work2( '$var++' ) . "\n"; print "Calling work3: " . temp1::work3( '$var++' ) . "\n"; print "Work3 again: " . temp1::work3( '++$var' ) . "\n"; print "Calling work4: " . temp1::work4( '$var++' ) . "\n";
The output is:package temp1; use strict; use warnings; my $var; sub init { $var = 101 } sub work1 { return eval shift; } sub work2 { my $foo = shift; return eval $foo; $var } sub work3 { return eval $_[0]; } sub work4 { eval $var; } 1;
Calling work1: 3 Calling work2: 101 Calling work3: 3 Work3 again: 5 Calling work4: 102
In reply to Re^2: quantum behavior in perl?
by mr_mischief
in thread quantum behavior in perl?
by b4swine
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |