in reply to Check script's dependencies

Interesting, but it doesn't work for me. I added Data::Dumper and took out the foreach and replaced it with print Dumper($p->used); Now it works for me.
#!/usr/bin/perl # Usage: checkdeps.pl SCRIPT # Check Perl script's dependencies use strict; use warnings; use Module::ExtractUse; use YAML; use YAML::Dumper; my $script = $ARGV[0] or die "Usage: $0 SCRIPT\n"; open SCRIPT, $script or die "$!\n"; my $code = join "", <SCRIPT>; close SCRIPT; my $p = Module::ExtractUse->new; $p->extract_use(\$code); my $dumper = YAML::Dumper->new; $dumper->indent_width(4); my @used = $p->array; print $dumper->dump($p->used);

Replies are listed 'Best First'.
Re^2: Check script's dependencies
by alexbio (Monk) on May 27, 2010 at 16:47 UTC

    Thank you for your help, but I think your code lost the main features I needed: the test on every module to check if it is installed and the "formatted output".

    I really don't understand what's wrong in my code, I tested it on both Linux (perl 5.10.1) and Windows XP (the latest strawberry perl). Has anyone more experienced than me any ideas?

    Alex's Log - http://alexlog.co.cc