Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Global destruction feature / bug ?

by ikegami (Pope)
on Apr 03, 2008 at 19:05 UTC ( #678245=note: print w/ replies, xml ) Need Help??

in reply to Global destruction feature / bug ?

When the scope (the file) ends, the last reference to $foo is released, so it's detroyed.

If any function (incl END) referenced $foo, it would capture the variable. In that case, there would still be a reference to the variable at the end of the file scope, so the variable will survive until global destruction.

use strict; use warnings; sub Foo::DESTROY{ print "object $_[0]->[0] destroyed\n"; } my $foo = bless [ 'foo' ], 'Foo'; # notice 'my' our $bar = bless [ 'bar' ], 'Foo'; # notice 'our' END { $foo; print "END block executed\n"; }
should produce
END block executed object foo destroyed object bar destroyed
Comment on Re: Global destruction feature / bug ?
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://678245]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2016-05-29 07:42 GMT
Find Nodes?
    Voting Booth?