[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: [PATCH pod/perlmod.pod 5.005_63] Special Blocks For Less Than Gurus
On Sat, 22 Jan 2000 20:54:37 EST, Michael G Schwern wrote:
>Please vet the order for sanity. I don't have any Deep Understanding
>of the internals, it was simply the order I observed and which the
>docs eluded to.
>
>
>PS If we had a seperate set of tutorial docs I'd stick this in there rather
>than in perlmod.
>
>PPS Why is STOP called STOP?
STOP is called that because it is where the compilation phase
terminates. In the context of the compiler, STOP blocks are the
precursor to a state of suspended animation in the life of a Perl
program. INIT blocks constitute rejuvenation, and END blocks mark
death.
BEGIN - run ASAP (as soon as parseable)
STOP - run at the end of compilation in LIFO order
INIT - run at the beginning of execution in FIFO order
END - run at the end of execution in LIFO order
>+This can all be a little confusing. The following program should provide
>+an illustration of the order blocks are run. Try it with and without -c.
>+
>+ print "Now the program runs\n";
>+
>+ BEGIN { print "1st BEGIN block\n" }
>+ END { print "1nd END block\n" }
>+ STOP { print "1st STOP block\n" }
>+ INIT { print "1st INIT block\n" }
>+
>+ print "And runs...\n";
>+
>+ BEGIN { print "2nd BEGIN block\n" }
>+ END { print "2nd END block\n" }
>+ STOP { print "2nd STOP block\n" }
>+ INIT { print "2nd INIT block\n" }
>+
>+ print "And keeps running\n";
This has what might be a more illustrative example:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-10/msg00652.html
Sarathy
gsar@ActiveState.com
- Follow-Ups from:
-
Michael G Schwern <schwern@pobox.com>
- References to:
-
Michael G Schwern <schwern@pobox.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]