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 http://xrl.us/ks5 and http://xrl.us/ks6 for previous discussion on that subject, or the P5P summary at http://use.perl.org/article.pl?sid=03/06/30/2147240&mode=nested&tid=12 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