Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 29.659.594 Times

AtExit 2.01

  Date Added: July 17, 2010  |  Visits: 519

AtExit

Report Broken Link
Printer Friendly Version


Product Homepage
Download (71 downloads)



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)..

Requirements: No special requirements
Platforms: Linux
Keyword: Atexit Libraries Perl Module Print Program Programming Registered Scope Subroutine Subroutines
Users rating: 0/10

License: Freeware Size: 8.19 KB
USER REVIEWS
More Reviews or Write Review


ATEXIT RELATED
Libraries  -  Acme::EyeDrops 1.51
Acme::EyeDrops is a Perl module for visual programming in Perl. SYNOPSIS use Acme::EyeDrops qw(sightly); print sightly( { Shape => camel, SourceFile => eyesore.pl } ); Acme::EyeDrops converts a Perl program into an equivalent one, but...
102.4 KB  
Libraries  -  Alien Perl module 0.91
Alien Perl module package contains external libraries wrapped up for your viewing pleasure! SYNOPSIS perldoc Alien; Alien is a package that exists just to hold together an idea, the idea of Alien:: packages, so there is no code here, just...
10.24 KB  
Libraries  -  Math::Combinatorics 0.09
Math::Combinatorics is a Perl module that can perform combinations and permutations on lists. SYNOPSIS Available as an object oriented API. use Math::Combinatorics; my @n = qw(a b c); my $combinat = Math::Combinatorics->new(count => 2,...
10.24 KB  
Libraries  -  XML::All 0.02
XML::All is a Perl module that contains overloaded XML objects. SYNOPSIS use XML::All; my $xml = 1 2 3 >; print $$xml; # a print join ", ", @$xml; # 1, 2 , 3 print...
25.6 KB  
Libraries  -  Locale::Maketext::Fuzzy 0.02
Locale::Maketext::Fuzzy is a Perl module for Maketext from already interpolated strings. SYNOPSIS package MyApp::L10N; use base Locale::Maketext::Fuzzy; # instead of Locale::Maketext package MyApp::L10N::de; use base MyApp::L10N; our...
6.14 KB  
Libraries  -  Bio::Tree::Compatible 1.5.2_102
Bio::Tree::Compatible is a Perl module for testing compatibility of phylogenetic trees with nested taxa. SYNOPSIS use Bio::Tree::Compatible; use Bio::TreeIO; my $input = new Bio::TreeIO(-format => newick, -file => input.tre); my $t1 =...
5.6 MB  
Libraries  -  Env::Path 0.18
Env::Path is a Perl module with advanced operations on path variables. SYNOPSIS use Env::Path; # basic usage my $manpath = Env::Path->MANPATH; $manpath->Append(/opt/samba/man); for ($manpath->List) { print $_, "n" }; # similar to above...
10.24 KB  
Libraries  -  Proc::Forking 1.38
Proc::Forking is a Perl module that provides a set of tool to fork and daemonize. SYNOPSIS #!/usr/bin/perl use strict; use Proc::Forking; use Data::Dumper; use Time::HiRes qw(usleep); # to allow micro sleep my $f = Proc::Forking->new();...
11.26 KB  
Libraries  -  Test::Reporter::Date::Format 1.27
Test::Reporter::Date::Format Perl module contains date formating subroutines. SYNOPSIS use Test::Reporter::Date::Format; @lt = localtime(time); print time2str($template, time); print strftime($template, @lt); print time2str($template,...
23.55 KB  
Libraries  -  OpenGeoDB Perl module 0.4
OpenGeDB Perl module is a module to access the OpenGeoDB database and calculate all ZIP codes in a certain radius..
3.07 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by freedesktop.org, it is used to describe information about an application such as the name and...
327.68 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB  
Libraries  -  wolfSSL 3.11.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
2.73 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB