Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Get path to module

by mjscott2702 (Pilgrim)
on Sep 28, 2010 at 08:41 UTC ( [id://862372]=perlquestion: print w/replies, xml ) Need Help??

mjscott2702 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am currently trying to reverse-engineer a fairly large Perl web application I have inherited, that relies heavily on the CGI and CGI::Template modules, as well as a host of custom modules.

There is a lot of manipulation of where perl locates the custom modules, and unfortunately, they seem to be duplicated in several places.

So, my simple (hopefully) question is - how do I find which "instance" of a module is actually used?

For example, with a statement such as:

my $util = new MyApp::Utilv2;

how can I find out which one of the several possibilities was actually invoked?

Yes, that should probably be written as

my $util = MyApp::Utilv2->new()

but like I said, I inherited this!

Utilities such as perlwhich etc probably won't help me here, since so much manipulation of @INC, use lib etc is going on.

Replies are listed 'Best First'.
Re: Get path to module
by Anonymous Monk on Sep 28, 2010 at 08:56 UTC
    $ perl -le " use strict; print for %INC" strict.pm C:/perl/5.10.1/lib/strict.pm

      OP got it, but just to be a bit more explicit for future monks (see also %INC):

      use MyApp::Utilv2; print qq!MyApp::Utilv2 was found at '$INC{"MyApp/Utilv2.pm"}'\n!;

      Good Day,
          Dean

        good old %INC, @INC's nerdy kid brother -- always knows the scoop.

      Perfect - just what I needed! Thanks!

Re: Get path to module
by mjscott2702 (Pilgrim) on Sep 28, 2010 at 08:47 UTC

    I should add - I am looking for something that is fairly generic - I want to avoid locating all possibilities, and adding in some code to make them identify themselves. The constructor simply returns an empty blessed hash.

    Additionally, running as a CGI application makes debugging difficult, so ideally I just want to add in some debug print statements (to a file) around the constructor call.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found