Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

Thanks

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/Carp.pm'};
    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/Dumper.pm"};
    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2014-09-17 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (81 votes), past polls