#!/usr/bin/perl -w use strict; { package Foo; $Foo::DCALLS = 0; sub new { bless {}, shift; } sub DESTROY { $Foo::DCALLS++; warn "DESTROY CALLED"; } } { my $foo = Foo->new; sub { print "FOO: $foo\n"; sub { print "FOO: $foo\n"; # comment this out and the destructor is c +alled }; }; } END { print "DCALLS: $Foo::DCALLS\n"; }
In reply to nested subs cause DESTROY block to not get hit by eak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |