Created
November 22, 2011 15:21
-
-
Save dann/1385916 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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