perlversionperlbrew

Perlbrew version number of latest stable version


I see perlbrew install can take a stable argument to install the latest, but I would like to get the latest stable version number to check against before installing.

How can I get the version number of the latest stable perl using perlbrew?


Solution

  • perlbrew available | perl -e'
       my @available_perls = <>;
       s/^\s+|\s+\z//g for @available_perls;
    
       my ($latest_ver, $latest_minor);
       for my $cand (@available_perls) {
          my ($ver, $minor) = $cand =~ m/^perl-(5\.(6|8|[0-9]+[02468])\.[0-9]+)$/
             or next;
    
          ($latest_ver, $latest_minor) = ($ver, $minor)
             if !defined $latest_minor
             || $latest_minor < $minor;
       }
    
       die "Can\x27t determine latest stable Perl release\n"
          if !defined $latest_ver;
    
       print "$latest_ver\n";
    '
    

    Effectively lifted straight out of App::perlbrew.


    If you had App::perlbrew installed, you could use the following:

    /path/to/perl/with/module/perl -MApp::perlbrew -e'
       my $latest_ver = App::perlbrew->new->resolve_stable_version;
       print "$latest_ver\n";
    '