Skip to content

Instantly share code, notes, and snippets.

@smeghead
Created July 16, 2012 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smeghead/3123259 to your computer and use it in GitHub Desktop.
Save smeghead/3123259 to your computer and use it in GitHub Desktop.
check missing modules.
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Data::Dumper;
die 'no argument.' if scalar @ARGV < 1;
my $check_path = $ARGV[0];
my $uses = `fgrep -r 'use ' $check_path | sed -e 's/.*use \\([A-Z][a-zA-Z0-9:]\\+\\).*/\\1/' | grep -v '^/' | sort | uniq`;
my @modules = split /\s/, $uses;
print "#-- missing modules list --\n";
for my $module (@modules) {
chomp $module;
eval("use $module;");
if ($@) {
print "cpanm $module\n";
}
}
print "#--------------------------\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment