Skip to content

Instantly share code, notes, and snippets.

@dann
Created November 22, 2011 15:21
Show Gist options
  • Save dann/1385916 to your computer and use it in GitHub Desktop.
Save dann/1385916 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use CPAN::FindDependencies;
our $is_depended = 0;
main();
exit;
sub main {
my $dist = $ARGV[0];
my $dependency = $ARGV[1];
check_dependency( $dist, $dependency );
report_dependency_check_result( $dist, $dependency );
}
sub check_dependency {
my ( $dist, $dependency ) = @_;
my @dependencies = CPAN::FindDependencies::finddeps($dist);
foreach my $dep (@dependencies) {
if($dep->name() =‾ /$dependency/) {
$is_depended = 1;
return;
}
}
}
sub report_dependency_check_result {
my ( $dist, $dependency ) = @_;
if ($is_depended) {
print "${dist} depends ${dependency}";
}
else {
print "${dist} doesn't depend ${dependency}";
}
}
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment