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

Hi - I'm trying to use scandeps to find the dependencies in my perl script. However, when I run it, I get no results. Perhaps my scandeps script is needing a little modification thought, I'm hoping that someone's eagle eyes can pick out what I am missing. Here is the script for ScanDeps:
use Module::ScanDeps; use strict; use warnings; my $hash_ref = scan_deps( files => [ 'c:\lib-authtest.cgi' ], recurse => 1, ); my $key; my $value; print "start:"; while (($key, $value) = each(%{$hash_ref})) { print $key.", ".$value."<br />"; }
And if you're interested, here is the script it is working on. Does ScanDeps output nothing if it finds no dependecies? Because the output from the following script seems to suggest it's still needing something.
#!/usr/bin/perl use warnings; use strict; #perl2exe_noopt "Opcode.pm" #perl2exe_exclude "Apache2/RequestRec.pm" #perl2exe_exclude "Apache2/RequestIO.pm" #perl2exe_exclude "Apache2/RequestUtil.pm" #perl2exe_exclude "APR/Pool.pm" #perl2exe_exclude "ModPerl/Util.pm" #perl2exe_exclude "Apache2/Response.pm" #Net::SMTP related: #perl2exe_exclude "Convert/EBCDIC.pm" #perl2exe_exclude "Mac/InternetConfig.pm" #xperl2exe_include "Authen/SASL.pm" use CGI::Carp qw(fatalsToBrowser); &Main; exit; ############################################ sub Main { print "Content-type: text/html;charset=UTF-8\n\n"; print <<NCP; <html> <head> <title>Library Search</title> </head><body> NCP use Net::SMTP; use MIME::Base64; use Authen::SASL; my $SMTPServer = 'myserver.net'; my $emailFrom = 'from@isp.com'; my $emailTo = 'to@isp.com'; my $NetSMTP = Net::SMTP->new($SMTPServer, Timeout=>60, Debug=>1) || +die "Unable to open connection to SMTP server named '$SMTPServer'.\nE +rror Message: $! \n"; my $user = 'user'; my $pass = 'pass'; print "<br>SMTP auth"; $NetSMTP->auth( $user, $pass ) || die "<br>Auth didn't work: $!<br>" +; print "<br>sending from [$emailFrom] to [$emailTo]"; $NetSMTP->mail($emailFrom); $NetSMTP->to($emailTo); $NetSMTP->data(); $NetSMTP->datasend('this is the body text'); $NetSMTP->quit; print "<br><br><b>Done.</b>"; }

Replies are listed 'Best First'.
Re: ScanDeps usage
by GrandFather (Saint) on Jul 19, 2012 at 02:16 UTC

    If I run the following code (noname.pl is the name of the file containing the script btw):

    use strict; use warnings; use Module::ScanDeps; my $hash_ref = scan_deps(files => ['noname.pl'], recurse => 1,); while (my ($key, $value) = each(%{$hash_ref})) { print "$key, $value<br />\n"; }

    I get over 800 lines of output starting:

    Set up gcc environment - 3.4.5 (mingw-vista special r3) unicore/lib/gc_sc/InBuhid.pl, HASH(0x64b47ac)<br /> unicore/lib/gc_sc/InGeomet.pl, HASH(0x64b7c84)<br /> unicore/lib/gc_sc/Knda.pl, HASH(0x64c073c)<br />

    Note the very first line (which is actually printed to STDERR)! That implies to me that you need a compiler available for the module to run correctly. Could that be your problem?

    True laziness is hard work
      Set up gcc environment - 3.4.5 (mingw-vista special r3)

      When you see that message on ActivePerl (which is the only place you'll ever see it) it tells you that ExtUtils::MakeMaker has been loaded ... not much more than that.

      It does, of course, also indicate that the MinGW compiler will be used if a compiler is needed for the task at hand - but, despite what a sane person might deduce from the message, it by no means indicates that a compiler *is* required.
      It also tells you that $ENV{ACTIVEPERL_CONFIG_DISABLE} (which is the means by which the message can be suppressed) has not been set to a true value ... and that's about the extent of it, afaik.

      Corrections: More accurately, you'll get the "Set up gcc environment" message when ActivePerl::Config::override{'arg'} is called - but only for some values of 'arg' (eg 'cc', 'make', 'ld').
      Loading EU::MM is one way for that to happen, but there are other ways (eg by loading Config.pm and querying $Config{cc}) to trigger the message that *don't* load EU::MM.
      The message can also be suppressed by setting $ENV{ACTIVEPERL_CONFIG_SILENT}. Setting $ENV{ACTIVEPERL_CONFIG_DISABLE} disables the entire alternative (MinGW) config set up completely, whereas you can still use MinGW with ActivePerl if $ENV{ACTIVEPERL_CONFIG_SILENT} is set.

      Cheers,
      Rob
Re: ScanDeps usage
by Khen1950fx (Canon) on Jul 19, 2012 at 04:55 UTC
    First, I tried scanning lib-authtest.cgi---nothing happened. Then I tried it as "lib-authtest": bingo. You'll also need to use a dumper for $value. Here's what worked for me on a hybrid Linux system:
    #!/usr/bin/perl -l use strict; use autodie; use warnings; use Module::ScanDeps; use Data::Dumper::Concise; my $hash_ref = scan_deps( files => [ '/root/Desktop/lib-authtest' ], recurse => 1, ); print "Now starting: \n"; while (my ($key, $value) = each(%{$hash_ref})) { print $key, Dumper($value); }
Re: ScanDeps usage
by Anonymous Monk on Jul 19, 2012 at 06:24 UTC

    Perhaps my scandeps script is needing a little modification thought

    Why aren't you using scandeps.pl the script?

    scandeps -Ccacheit -x lib-authtest.cgi

ScanDeps alternatives
by dolmen (Beadle) on Jul 19, 2012 at 11:38 UTC