Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: call a modules INIT-section (B tricks)

by ysth (Canon)
on Dec 20, 2004 at 02:43 UTC ( #416098=note: print w/ replies, xml ) Need Help??


in reply to call a modules INIT-section

It is, but it is only easily possible (that is, without using special XS code) for 5.8.1 and above.

# pass a module name # returns list or count of coderefs for unrun INITs in the given modul +e # empty list/undef if something goes wrong sub get_inits_for_module { use 5.008001; use B; my $mod = shift; eval { map $_->object_2svref, grep $_->GV->STASH->NAME eq $mod, B::init_av->ARRAY } }
Remove the grep line to get unrun INITs for any module.

In general, any module should provide something that can be called to initialize it for circumstances where INIT doesn't get run, so you shouldn't ever have to do this.


Comment on Re: call a modules INIT-section (B tricks)
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://416098]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-08-28 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls