Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 66321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:05:06+00:00 2026-05-10T19:05:06+00:00

Does anyone have any suggestions for a good approach to finding all the CPAN

  • 0

Does anyone have any suggestions for a good approach to finding all the CPAN dependencies that might have arisen in a bespoke development project. As tends to be the case your local development environment rarely matches your live one and as you build more and more projects you tend to build up a local library of installed modules. These then lead to you not necessarily noticing that your latest project has a requirement on a non-core module. As there is generally a requirement to package the entire project up for deployment to another group (in our case our operations team), it is important to know what modules should be included in the package.

Does anyone have any insights into the problem.

Thanks

Peter

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:05:06+00:00Added an answer on May 10, 2026 at 7:05 pm

    I’ve had this problem myself. Devel::Modlist (as suggested by this answer) takes a dynamic approach. It reports the modules that were actually loaded during a particular run of your script. This catches modules that are loaded by any means, but it may not catch conditional requirements. That is, if you have code like this:

    if ($some_condition) { require Some::Module } 

    and $some_condition happens to be false, Devel::Modlist will not list Some::Module as a requirement.

    I decided to use Module::ExtractUse instead. It does a static analysis, which means that it will always catch Some::Module in the above example. On the other hand, it can’t do anything about code like:

    my $module = 'Other::Module'; eval 'use $module;'; 

    Of course, you could use both approaches and then combine the two lists.

    Anyway, here’s the solution I came up with:

    #! /usr/bin/perl #--------------------------------------------------------------------- # Copyright 2008 Christopher J. Madsen <perl at cjmweb.net> # # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either the # GNU General Public License or the Artistic License for more details. # # Recursively collect dependencies of Perl scripts #---------------------------------------------------------------------  use strict; use warnings; use File::Spec (); use Module::CoreList (); use Module::ExtractUse ();  my %need; my $core = $Module::CoreList::version{'5.008'};  # These modules have lots of dependencies.  I don't need to see them now. my %noRecurse = map { $_ => 1 } qw(   Log::Log4perl   XML::Twig );  foreach my $file (@ARGV) {   findDeps($file); }  foreach my $module (sort keys %need) {   print '  $module\n'; }  #--------------------------------------------------------------------- sub findDeps {   my ($file) = @_;    my $p = Module::ExtractUse->new;    $p->extract_use($file);    foreach my $module ($p->array) {     next if exists $core->{$module};     next if $module =~ /^5[._\d]+/; # Ignore 'use MIN-PERL-VERSION'     next if $module =~ /\$/;        # Run-time specified module      if (++$need{$module} == 1 and not $noRecurse{$module}) {       my $path = findModule($module);       if ($path) { findDeps($path) }       else       { warn 'WARNING: Can't find $module\n' }     } # end if first use of $module   } # end foreach $module used } # end findDeps  #--------------------------------------------------------------------- sub findModule {   my ($module) = @_;    $module =~ s!::|\'!/!g;   $module .= '.pm';    foreach my $dir (@INC) {     my $path = File::Spec->catfile($dir, $module);     return $path if -f $path;   }    return; } # end findModule 

    You’d run this like:

    perl finddeps.pl scriptToCheck.pl otherScriptToCheck.pl 

    It prints a list of all non-core modules necessary to run the scripts listed. (Unless they do fancy tricks with module loading that prevent Module::ExtractUse from seeing them.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have any suggestions for a good tool, xslt or other that can
Does anyone have any good suggestions for creating a Pipe object in Java which
Does anyone have any suggestions for a good way to call R from S-Plus?
Does anyone have any suggestions for a good cross platform input library? I'd like
Does anyone have any suggestions on how to mentor a junior programmer ? If
Does anyone have any suggestions (or a regular expression) for parsing the HTTP Accept
Does anyone have any suggestions as to how I can clean the body of
Does anyone have any suggestions for creating meta tables in a database? These tables
Does anyone have any suggestions on how to edit an <a href=''> link in
Does anyone have any suggestions about where I can find a C# implementation for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.