Created
August 20, 2010 00:11
-
-
Save juster/539268 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 warnings; | |
use strict; | |
use version; | |
my @data_sources = ( [ 'qv()' => sub { qv( shift ) } ], | |
[ 'version->new()' => sub { version->new( shift ) } ], | |
); | |
my @methods = ( [ 'raw' => sub { shift } ], | |
[ 'numify' => sub { shift->numify } ], | |
[ 'stringify' => sub { shift->stringify } ], | |
); | |
my $colcount = ( scalar @methods ); | |
my $rowfmt = sprintf "%s\n", join q{ }, | |
'%15s', ( "%10s" ) x $colcount; | |
for my $verstr ( @ARGV ) { | |
my ( @data_names, @data_results ); | |
for my $data_source ( @data_sources ) { | |
my ( $name, $data_ref ) = @$data_source; | |
my $data = $data_ref->( $verstr ); | |
push @data_results, [ $name, | |
map { | |
eval { $_->[ 1 ]->( $data ) } or "N/A" | |
} @methods ]; | |
} | |
print "\n"; | |
printf $rowfmt, qq{"$verstr"}, map { $_->[0] } @methods; | |
for my $row_result ( @data_results ) { | |
printf $rowfmt, @$row_result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment