AtExit
view release on metacpan or search on metacpan
lib/AtExit.pm view on Meta::CPAN
## Get the remaining arguments
my ($exit_sub, @args) = @_;
return 0 if ($self->{EXITING} and $self->{IGNORE_WHEN_EXITING});
unless (ref $exit_sub) {
## Caller gave us a sub name instead of a sub reference.
## Need to make sure we have the callers package prefix
## prepended if one wasn't given.
my $pkg = '';
$pkg = (caller)[0] . "::" unless $exit_sub =~ /::/o;
## Now turn the sub name into a hard sub reference.
$exit_sub = eval "\\&$pkg$exit_sub";
undef $exit_sub if ($@);
}
return 0 unless (defined $exit_sub) && (ref($exit_sub) eq 'CODE');
## If arguments were given, wrap the invocation up in a closure
my $subref = (@args > 0) ? sub { &$exit_sub(@args); } : $exit_sub;
( run in 0.413 second using v1.01-cache-2.11-cpan-a3c8064c92c )