Created
June 20, 2017 03:28
-
-
Save ltriant/f4d7fa6f0650bc024476994d9d4ff82c to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env perl | |
| use warnings; | |
| use strict; | |
| use Mojo::UserAgent; | |
| die "usage: cpanver <module>\n" unless @ARGV; | |
| my ($module) = @ARGV; | |
| my $url = sprintf 'http://fastapi.metacpan.org/v1/package/%s', $module; | |
| my $ua = Mojo::UserAgent->new; | |
| my $path = $module; | |
| $path =~ s{::}{/}g; | |
| $path =~ s{$}{.pm}; | |
| eval { require $path }; | |
| my $ver = $@ ? "not installed" : $module->VERSION; | |
| print "Installed: $ver\n"; | |
| my $tx = $ua->get($url); | |
| if ($tx->res->is_success) { | |
| my $json = $tx->res->json; | |
| print "Latest: ", $json->{version}, "\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment