Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Just another Perl shrine

Module usage

by ezekiel (Pilgrim)
on Jul 22, 2002 at 01:15 UTC ( #183907=perlquestion: print w/ replies, xml ) Need Help??
ezekiel has asked for the wisdom of the Perl Monks concerning the following question:

I have a CGI script using a number of modules (objects) to handle the guts of the processing work. While trying to debug this script I added a warn message to the module I thought the script was using. This warn message never appeared in the logs.

For better or for worse (probably worse), there are multiple copies of this particular module strewn around the file system. Is there any easy way to check the file location of the module whenever a new instance of the object or a method call is made to make sure I am editing the right piece of code in trying to fix bugs


Comment on Module usage
Re: Module usage
by Chmrr (Vicar) on Jul 22, 2002 at 01:30 UTC

    After you load the module(s), print out the %INC global. This will tell you the locations of the files which have been included via use or require; for example, try perl -e 'require CGI; use Data::Dumper; print Dumper(\%INC)'

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Re: Module usage
by clintp (Curate) on Jul 22, 2002 at 01:30 UTC
    The hash %INC might have your answer:
    use CGI::Carp; print $INC{'CGI/'};
    Would pull in that module, and then tell you where it found the code at.
Re: Module usage
by dpuu (Chaplain) on Jul 22, 2002 at 01:31 UTC
    You can use %INC. Its like @INC, only the hash key is the name of the file you want to find. For example:
    use Data::Dumper; print $INC{"Data/"};
    A slight bug in this (IMHO) is that you can't use a module name (i.e. $INC{"Data::Dumper"} won't work). You have to use the filename of the module. Oh, and you have to "use" or "require" the module before %INC includes the module's file. --Dave.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://183907]
Approved by erikharrison
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-04-16 10:57 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (424 votes), past polls