On Fri, Dec 03, 2004 at 01:01:20AM +0100, Paul Johnson <paul@pjcj.net> wrote: > Devel::Cover does just this. It's something of an unholy mix of XS and > perl subs for various arcane reasons, at least some of which are > unlikely to be valid any more. > > The way it works is that in a CHECK block an XS sub is called which > installs a perl sub as as the first END sub. This is done by unshifting > onto PL_endav. When that sub is called as the first END sub it calls > another XS sub which installs another perl sub as the last END sub by > pushing it onto PL_endav. That newly installed sub should be the last > END sub called. Unless one of the subsequent END subs installs another > END sub. Does the first END sub do something else also? Why not skip the CHECK and just have a regular END sub that inserts a last END sub? No dedicated XS needed, at least as of 5.8.1: perl -we'use B qw/end_av/; END { print "baz" } END {print "bar"; push @{end_av()->object_2svref}, sub { print "quux" } } END { print "foo" }'Thread Previous | Thread Next