Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Was a module use'd or require'd? (CHECK?)

by tye (Cardinal)
on Aug 13, 2007 at 14:52 UTC ( #632231=note: print w/ replies, xml ) Need Help??


in reply to Re: Was a module use'd or require'd?
in thread Was a module use'd or require'd?

I haven't tried to lay it out clearly, but it seems to me that this node works under the flawed but common (it seems) assumption that there is some one "compile time" followed by some one "run time". Each line of code has one "compile time" and zero or more "run times" and those intermix quite a bit in even simple cases. The CHECK block of one module seems unlikely to be reliably run between the "compile time" and "run time" of some other module.

Without checking (since "perldoc -f CHECK" and other similar attemps to easily find the relevent documentation are likely all still useless), your use makes me guess that CHECK blocks are the ones that get run after the main script has finished compiling. So this would only be useful for distinguishing mundane use vs require from the main script.

So I don't think that addresses the requested problem at all, which is trying to reconstruct whether Some::Module should be reconstructed as having used or as having required each of the modules it loaded.

- tye        


Comment on Re^2: Was a module use'd or require'd? (CHECK?)
Re^3: Was a module use'd or require'd? (CHECK?)
by Anno (Deacon) on Aug 13, 2007 at 16:56 UTC
    I think you are right. My method will tell whether a module was loaded before or after the main program was compiled, not whether it was a "use" or "require" statement that did the loading. It would be useless for the given purpose (about which I wans't quite clear when I wrote the reply).

    Putting a subref on @INC looks like the best bet. It should be possible to tell the cases from another by looking at some levels of caller(). One problem here is to make sure you are always called. If someone unshifts new components onto @INC in front of you, you may never be for some modules.

    Update: tie-ing @INC could help. It isn't magical, so tie should be no problem.

    Anno

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-08-20 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (116 votes), past polls