in reply to Re^2: Variables out of scope using END and Error.pm
in thread Variables out of scope using END and Error.pm
I'm not sure if that explenation is 100% correct...On the other hand, I am sure :-)
The only difference between END and a normal sub in this case is that the END is called after the variable has normally gone out of scope. The following demonstrates the buggy behaviour for ordinary subs (on perl < 5.9.0) by artifically reducing the scope of the variable
{ my $x = 1; sub foo { # commenting this out causes the print to see an undef value $x; sub { print "x=$x\n" }->(); } } foo();
Dave.
|
|---|