Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

RE: Find perl module version from command-line

by Fastolfe (Vicar)
on Oct 18, 2000 at 02:27 UTC ( [id://37242] : note . print w/replies, xml ) Need Help??

in reply to Find perl module version from command-line

Things like this are frequently done in conjunction with CPAN lookups. Many people don't realize that the CPAN module itself can be used in your own scripts. You can extend lachoy's example a lot further by using CPAN, at the expense of a lot of time:
#!/usr/bin/perl use CPAN; printf("%-20s %10s %10s\n", "Module", "Installed", "CPAN"); foreach $a (@ARGV) { foreach $mod (CPAN::Shell->expand("Module", $a)){ printf("%-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 ? "" : "*" ); } }
Running with arguments: DBI /DBD::/
Module Installed CPAN DBI 1.13 1.14 * DBD::ADO 0.14 1.17 * DBD::ASAny - 1.09 * DBD::Adabas - 0.2003 * DBD::Altera - - * DBD::CSV - 0.1024 *
...etc. Though if all you're interested in is the installed version of modules, you're FAR better off going with lachoy's script, since the code above will rely upon CPAN data, which will require time to fetch, extract and browse.