Skip to content

Instantly share code, notes, and snippets.

@artifactsauce
Created November 18, 2010 04:17
Show Gist options
  • Save artifactsauce/704621 to your computer and use it in GitHub Desktop.
Save artifactsauce/704621 to your computer and use it in GitHub Desktop.
List installed perl modules
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use ExtUtils::Installed;
use List::Util;
my %options = ();
GetOptions(
'table' => \$options{table},
);
my $ei = ExtUtils::Installed->new;
my $length = List::Util::max( map { length($_) } $ei->modules );
if ( $options{'table'} ) {
require Text::SimpleTable;
my $table = Text::SimpleTable->new( $length, 10 );
$table->row( 'Module Name', 'Version' );
$table->hr;
$table->row( $_, $ei->version($_) ) for $ei->modules;
print $table->draw;
}
else {
printf "%-${length}s %s\n", $_, $ei->version($_) for $ei->modules;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment