Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Was a module use'd or require'd?by Anno (Deacon) |
on Aug 13, 2007 at 12:09 UTC ( [id://632189]=note: print w/replies, xml ) | Need Help?? |
One idea would be to make a snapshot of %INC when compile time ends. If an entry is in the snapshot, the module was use()d, otherwise it was require()d.
For instance: Here, report() simply prints a list with each module's status. A more elaborate version could return the status of a module that is passed in. Of course, %INC can be manipulated in every which way, so the method isn't fool-proof. It makes up for that with simplicity.
Update: Anno
In Section
Seekers of Perl Wisdom
|
|