Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

How do you audit what Perl modules you use?

by talexb (Canon)
on May 09, 2005 at 17:13 UTC ( #455239=perlquestion: print w/ replies, xml ) Need Help??
talexb has asked for the wisdom of the Perl Monks concerning the following question:

The company I work for is getting ready to roll out some servers installed with our software, and it's my job to track down which modules we use and what copyrights and licenses apply to each module.

Is there any tool that exists to track down what modules a web application uses? I can imagine writing something simple (heh) that has a look at what modules are used in our modules and scripts and following that back to CPAN, but as usual I'm thinking about the meta-issue, because I'm going to want to do this again for this project, and in future for other projects.

And, as we're developing on RedHat 9 system, I need to do a similar dependency thing on the various RPMs that I've used, along with cases like A -> (depends on) B, B -> C, C-> D, D -> E but don't worry about E, we'll just install D with nodeps it'll be OK, trust me ..

I need to document that as well -- I'll probably use our Wiki, but it would be neater if I could put it into a database.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Comment on How do you audit what Perl modules you use?
Select or Download Code
Re: How do you audit what Perl modules you use?
by polettix (Vicar) on May 09, 2005 at 17:22 UTC
    Today I read merlyn pointing someone to PAR, which should be useful in your case.

    Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

    Don't fool yourself.

      The node of merlyn's to which frodo72 was referring was this one, in case anyone was wondering.

      PAR is useful when packaging up a Perl application. In my case I'm trying to find out what modules my application uses .. so I may just roll my own application.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        Sure, but I've seen in the PAR documentation that it has some heuristic to decide which modules to include; this could be useful in your case, I think, because I hope they've already worked out the problem of eliminating modules that are distributed together with Perl, saving you time to reproduce such a behaviour.

        Update: I now see that the heuristic comes from Module::ScanDeps (this is in pp documentation).

        Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

        Don't fool yourself.

        Well, I tried installing PAR and got

        Warning: prerequisite Compress::Zlib 1.3 not found. We have 1.16.
        which puzzles me a little .. couldn't find version 1.3, only version 1.16? Isn't that a good thing? And there's no workaround?

        I guess I'll pass on PAR for now and go ahead with the brute-force method.

        Alex / talexb / Toronto

        "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: How do you audit what Perl modules you use?
by sh1tn (Priest) on May 09, 2005 at 18:00 UTC
    You may want to try shell command like:
    $ egrep -rh '^use ' | sort -u
    where most of the 'use ' strings will be modules.


Re: How do you audit what Perl modules you use?
by cbrandtbuffalo (Deacon) on May 09, 2005 at 18:14 UTC
    I just posted a script that tries to help with the dependency bit. It uses Module::Dependency which builds a database of installed modules for you.

    Warning: It's only been lightly tested at this point.

Re: How do you audit what Perl modules you use?
by lithron (Chaplain) on May 09, 2005 at 19:05 UTC
    A little something I stole from the monestary recently. I wish I'd have commented the code with who the user that posted it was.
    END { print STDERR "Modules used:\n", map { " $_\n" } values %INC; }
      Of course this will only show you what modules were actually used on a particular run of the program. That's not guaranteed to get you every module that may be used in your code, e.g. if you require a module in some conditional, to name just one possible way to avoid acutally using modules mentioned in your code.

      --DrWhy

      "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Re: How do you audit what Perl modules you use?
by steves (Curate) on May 09, 2005 at 20:01 UTC
    use strict; use CPANPLUS::Backend; my $cpan = CPANPLUS::Backend->new(); foreach my $module ($cpan->installed()) { print $module->name(), "\n"; }
Re: How do you audit what Perl modules you use?
by ihb (Deacon) on May 09, 2005 at 20:02 UTC

Log In?
Username:
Password:

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

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

    Is guessing a good strategy for surviving in the IT business?





    Results (173 votes), past polls