develooper Front page | perl.perl5.porters | Postings from December 2003

Re: [DOCPATCH] BEGIN, CHECK, INIT, END explained more

Thread Previous | Thread Next
Rafael Garcia-Suarez
December 3, 2003 05:23
Re: [DOCPATCH] BEGIN, CHECK, INIT, END explained more
Message ID:
Arthur Bergman wrote:
> >
> > What's needed IMO is yet another special code block -- COMPILED, START,
> > better names welcome -- run when the compilation of the said 
> > compilation
> > unit ends, regardless of the state of the main perl interpreter.
> >
> No I disagree, I want to know apply the B::module magic after I require 
> something runtime too.

So write another B:: loader -- see below

> I guess what we need is a hook that gets called whenever a compilation 
> of a outer lexical scope (file, eval"") is completed.

A START block, then. So

    eval q{
	BEGIN { print 1; }
	START { print 2; }
	CHECK { print 3; }
	INIT  { print 4; }
	        print 5;
	END   { print 6; }
    print 7;

would print "12576".

You could then write an alternative to that loads B::* from
a START block instead of from a CHECK block. The whole CHECK magic
is entirely done in O -- there's no reason to stop poeple from using
B:: modules apart from the O framework.

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