develooper Front page | perl.perl5.porters | Postings from May 2012

Re: [perl #47027] Documentation: BEGIN, END docs in wrong section

Thread Previous | Thread Next
Denis Howe
May 5, 2012 01:16
Re: [perl #47027] Documentation: BEGIN, END docs in wrong section
Message ID:
On Fri 2012-05-04 07:13:17, wrote:

> The section "BEGIN, CHECK, INIT and END" in the
> "perlmod" docs has nothing to do with modules and should
> be moved to the "perlsyn" "Compound Statements" section
> where any reasonable person would expect to find it.

tchrist1 via RT <> wrote:

> Things like UNITCHECK and END are used as per-module setup and cleanup code

I can't believe I'm arguing with Tom :-) but...

Many Perl features are relevant to good module design but that doesn't
mean they should all be documented in perlmod.  These special blocks
are not specific to modules, they can be used in "eval" strings for

> these are *subroutines*.

So why does the doc say that it is not good style to prefix them with
"sub"?  Because they don't behave like subroutines in any way - you
can't call them, they don't take arguments or return anything.  (In
fact the option to prefix them with sub sounds like a confusing,
historic wart that should be retired.)

> They are not control statements like if, while, ....

That is quite clearly exactly what they are - special control
statements.  They are all about flow of control, just like if, while
and the rest.  The only difference is that these special blocks
control flow around the parsing and compilation phases as well as just
during execution.  If anything they are like the mythical "come from"
statements (

> control stuctures go in perlsyn.


> There is an argument to be made that they belong in perlsub

Only if you can convince us they are subroutines.

> but you cannot say they are unrelated to modules.

Not unrelated, but not specific to modules.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About