in reply to Re^3: if(my) scope
in thread if(my) scope
case in point:
package H; sub DESTROY { print "DESTROY\n"; } sub new { my $class = shift; bless {}, $class; } { if(my $h = H->new()) { print "IN\n"; undef $h; } print "\$h out of scope\n"; } print "why now?\n";
produces:
IN DESTROY $h out of scope why now?
As does:
package H; sub DESTROY { print "DESTROY\n"; } sub new { my $class = shift; bless {}, $class; } { { if(my $h = H->new()) { print "IN\n"; } } print "\$h out of scope\n"; } print "why now?\n";
|
---|
In Section
Seekers of Perl Wisdom