Main > Programming > Libraries >

AtExit 2.01

AtExit 2.01

Sponsored Links

AtExit 2.01 Ranking & Summary

RankingClick at the star to rank
Ranking Level
User Review: 0 (0 times)
File size: 0.008 MB
Platform: Any Platform
License: Perl Artistic License
Price:
Downloads: 886
Date added: 2007-05-23

AtExit 2.01 description

AtExit is a Perl module that can perform exit processing for a program or object.

SYNOPSIS

use AtExit;

sub cleanup {
my @args = @_;
print "cleanup() executing: args = @argsn";
}

## Register subroutines to be called when this program exits

$_ = atexit(&cleanup, "This call was registered first");
print "first call to atexit() returned $_n";

$_ = atexit("cleanup", "This call was registered second");
print "second call to atexit() returned $_n";

$_ = atexit("cleanup", "This call shouldve been unregistered by rmexit");
rmexit($_) or warn "couldnt unregister exit-sub $_!";

if (@ARGV == 0) {
## Register subroutines to be called when this lexical scope is exited
my $scope1 = AtExit->new( &cleanup, "Scope 1, Callback 1" );
{
## Do the same for this nested scope
my $scope2 = AtExit->new;
$_ = $scope2->atexit( &cleanup, "Scope 2, Callback 1" );
$scope1->atexit( &cleanup, "Scope 1, Callback 2");
$scope2->atexit( &cleanup, "Scope 2, Callback 2" );
$scope2->rmexit($_) or warn "couldnt unregister exit-sub $_!";

print "*** Leaving Scope 2 ***n";
}
print "*** Finished Scope 2 ***n";
print "*** Leaving Scope 1 ***n";
}
print "*** Finished Scope 1 ***n" if (@ARGV == 0);

END {
print "*** Now performing program-exit processing ***n";
}

The AtExit module provides ANSI-C style exit processing modeled after the atexit function in the standard C library (see atexit(3C)). Various exit processing routines may be registered by calling atexit and passing it the desired subroutine along with any desired arguments. Then, at program-exit time, the subroutines registered with atexit are invoked with their given arguments in the reverse order of registration (last one registered is invoked first). Registering the same subroutine more than once will cause that subroutine to be invoked once for each registration.

An AtExit object can be created in any scope. When invoked as a function, atexit registers callbacks to be executed at program-exit time. But when invoked as an object-method (using the $object->method_name syntax), callbacks registered with an AtExit object are executed at object-destruction time! The rules for order of execution of the registered subroutines are the same for objects during object-destruction, as for the program during program-termination.

The atexit function/method should be passed a subroutine name or reference, optionally followed by the list of arguments with which to invoke it at program/object exit time. Anonymous subroutine references passed to atexit act as "closures" (which are described in perlref). If a subroutine name is specified (as opposed to a subroutine reference) then, unless the subroutine name has an explicit package prefix, it is assumed to be the name of a subroutine in the callers current package. A reference to the specified subroutine is obtained, and, if invocation arguments were specified, it is "wrapped up" in a closure which invokes the subroutine with the specified arguments. The resulting subroutine reference is added to the front of the list of exit-handling subroutines for the program (atexit) or the AtExit object ($exitObject->atexit) and the reference is then returned to the caller (just in case you might want to unregister it later using rmexit. If the given subroutine could not be registered, then the value zero is returned.

The rmexit function/method should be passed one or more subroutine references, each of which was returned by a previous call to atexit. For each argument given, rmexit will look in the list of exit-handling subroutines for the program (rmexit) or the AtExit object ($exitObject->rmexit) and remove the first matching entry from the list. If no arguments are given, then all program or object exit-handlers are unregistered! The value returned will be the number of subroutines that were successfully unregistered.

At object destruction time, the DESTROY{} subroutine in the AtExit module iterates over the subroutine references in the AtExit object and invokes each one in turn (each subroutine is removed from the front of the queue immediately before it is invoked). At program-exit time, the END{} block in the AtExit module iterates over the subroutines in the array returned by the exit_subs method and invokes each one in turn (each subroutine is removed from the front of the queue immediately before it is invoked). Note that in both cases (program-exit, and object-destruction) the subroutines in this queue are invoked in first-to-last order (the reverse order in which they were registered with atexit).

AtExit 2.01 Screenshot

Advertisements

AtExit 2.01 Keywords

Bookmark AtExit 2.01

Hyperlink code:
Link for forum:

AtExit 2.01 Copyright

WareSeeker periodically updates pricing and software information of AtExit 2.01 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of AtExit 2.01 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed

Allok Video Splitter 2.2.0 Review:

Name (Required)
Email(Required)
Captcha
Featured Software

Want to place your software product here?
Please contact us for consideration.

Contact WareSeeker.com
Related Software
B::LexInfo is a Perl module that shows information about subroutine lexical variables. Free Download
Tie::Eudora is a Perl module that can encode/decode emails, read/write emails in Eudora mailbox files. Free Download
Data::Secs2 is a Perl module to pack, unpack, format, transform from Perl data SEMI E5-94 nested data. Free Download
IO::Multiplex is a Perl module that can manage IO on many file handles. Free Download
Data::Startup is a Perl module with startup options class, override, config methods. Free Download
Tk::PerlMethodList is a Perl module to query the Symbol-table for methods (subroutines) defined in a class (package). Free Download
Tie::Form is a Perl module to access a machine readable database file that minics a hardcopy form. Free Download
Nasal is a simple, small, yet full-featured embeddable scripting language. Free Download