in reply to Is possible to force the execution of a END block at runtime, without need to start global destruction?
So there I've created a subroutine (that I've snuck into B) that will execute the END blocks for the current package.use B; sub B::exec_ENDs { my $pkg = caller; $_->object_2svref->() for grep { $_->GV->STASH->NAME eq $pkg } B::end_av->ARRAY; } { package foo; sub pretend_to_leave { B->exec_ENDs(); print "I'll go get my coat ...\n"; } END { print "... another END block\n" } END { print "foo: this will be followed by " } } foo->pretend_to_leave(); END { print "main: Right, I'm outta here\n" } __output__ foo: this will be followed by ... another END block I'll go get my coat ... main: Right, I'm outta here foo: this will be followed by ... another END block
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Is possible to force the execution of a END block at runtime, without need to start global destruction?
by gmpassos (Priest) on May 21, 2004 at 04:41 UTC | |
|
Re: Re: Is possible to force the execution of a END block at runtime, without need to start global destruction?
by gmpassos (Priest) on May 23, 2004 at 02:40 UTC |