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

Re: Problem with attributes not running from do()

Thread Previous | Thread Next
Rafael Garcia-Suarez
October 6, 2003 10:10
Re: Problem with attributes not running from do()
Message ID:
Daisuke Maki wrote:
> But the behavior difference was just a surprise when I initially tried 
> doing that with attributes. When I was first testing my attribute on a 
> simple script it worked with no problem, and then I plugged it into the 
> production environment and the attributes didn't even run, simply 
> because of the do() call. Most everything else works exactly the same 
> when you just launch a program from the main perl interpreter or source 
> it in via do(), why should this be different?
> My question is, why can't this behavior be standardized across the 
> board? Symbol names are pretty darn useful, so it makes sense to run the 
> handler at CHECK time, so why can't code sourced in via do also run 
> CHECK blocks? This is especially confusing because BEGIN blocks are run, 
> even for do().
> # I guess if this is a issue in perl that cannot be fixed, it just
> # may be a good idea to include a big warning that CHECK and INIT
> # blocks are not run from do() and others, as well as on the
> # Attributes::Handler POD. It took me quite a while to find out
> # that that was the culprit.

Yes, the easiest solution is to add a warning that CHECK and INIT blocks
are run *only once* during the whole life time of the perl interpreter.

See and for previous discussion on
that subject, or the P5P summary at

Perhaps should we create another special block that is run just after
the compilation of its compilation unit finished. Or something. I don't
know how Attribute::Handlers works, or why it has been chosen to run
them at CHECK-time by default.

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