----- Original Message -----
From: "Uwe Mayer" <[EMAIL PROTECTED]>
> BTW: where are the BEGIN() and END() functions documented?
in perldoc perlsub
Functions whose names are in all upper case are reserved to the Perl
core,
as are modules whose names are in all lower case. A function in all
capitals is a loosely-held convention meaning it will be called
indirectly
by the run-time system itself, usually due to a triggered event.
Functions
that do special, pre-defined things include "BEGIN", "CHECK", "INIT",
"END", "AUTOLOAD", "CLONE" and "DESTROY"--plus all functions mentioned
in
perltie.
.... later it mentions
See "Package Constructors and Destructors" in perlmod about the special
triggered functions, "BEGIN", "CHECK", "INIT" and "END".
in perldoc perlmod
Package Constructors and Destructors
Four special subroutines act as package constructors and destructors.
These are the "BEGIN", "CHECK", "INIT", and "END" routines. The "sub" is
optional for these routines.
A "BEGIN" subroutine is executed as soon as possible, that is, the
moment
it is completely defined, even before the rest of the containing file is
parsed. You may have multiple "BEGIN" blocks within a file--they will
execute in order of definition. Because a "BEGIN" block executes
immediately, it can pull in definitions of subroutines and such from
other
files in time to be visible to the rest of the file. Once a "BEGIN" has
run, it is immediately undefined and any code it used is returned to
Perl's memory pool. This means you can't ever explicitly call a "BEGIN".
An "END" subroutine is executed as late as possible, that is, after perl
has finished running the program and just before the interpreter is
being
exited, even if it is exiting as a result of a die() function. (But not
if
it's polymorphing into another program via "exec", or being blown out of
the water by a signal--you have to trap that yourself (if you can).) You
may have multiple "END" blocks within a file--they will execute in
reverse
order of definition; that is: last in, first out (LIFO). "END" blocks
are
not executed when you run perl with the "-c" switch, or if compilation
fails.
Inside an "END" subroutine, $? contains the value that the program is
going to pass to "exit()". You can modify $? to change the exit value of
the program. Beware of changing $? by accident (e.g. by running
something
via "system").
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs