Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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

by tye (Sage)
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?)

Replies are listed 'Best First'.
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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://632231]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-04-23 00:20 GMT
Find Nodes?
    Voting Booth?