in reply to INIT blocks and runtime code loading
And some usage codepackage testpkg; BEGIN { warn "in BEGIN\n" } { no warnings; INIT { return if $INIT_DONE++; warn "in INIT\n"; } } { use B; $_->object_2svref->() for grep { $_->GV->STASH->NAME eq __PACKAGE__ } B::init_av->ARRAY; } 1;
Unfortunately it uses a rather horrific bodge of a package variable and post-increment behaviour, but nonetheless, it works :) Hopefully there's some very straight-forward solution for determining what state perl is in when a piece of code is executing, but currently I'm out of ideas.$ perl -we 'use testpkg;' in BEGIN in INIT $ perl -we 'require testpkg;' in BEGIN in INIT
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: INIT blocks and runtime code loading
by jdhedden (Deacon) on Jun 24, 2005 at 14:10 UTC |