#!perl
# from : http://www.perlmonks.org/?node=37237
# 07/08/2008 geoff mclane http://geoffair.net/mperl
use CPAN;
my @lines = ();
my $msg = '';
$msg = sprintf("%-20s %10s %10s\n", "Module", "Installed", "CPAN");
push(@lines, $msg);
foreach $a (@ARGV) {
  foreach $mod (CPAN::Shell->expand("Module", $a)){
    $msg = sprintf("%-20s %10s %10s %s\n",
      $mod->id,
      $mod->inst_version eq "undef" || !defined($mod->inst_version)
        ? "-" : $mod->inst_version,
      $mod->cpan_version eq "undef" || !defined($mod->cpan_version)
        ? "-" : $mod->cpan_version,
      $mod->uptodate ? "" : "*"
    );
    push(@lines,$msg);
  }
}

if (scalar @lines > 1) {
    foreach my $line (@lines) {
        print $line;
    }
}
# eof - modvers.pl
