0

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?

Rorschach
  • 31,301
  • 5
  • 78
  • 129
  • Do you want a programmatic solution, or do you want instructions for a human? – ikegami Sep 01 '19 at 05:27
  • it's part of a script, so programmatic. I'd be fine using git tags alternatively, but I can't determine how perl marks a git tag as stable either -- I was thinking about just grabbing the latest one that had a `-RC` – Rorschach Sep 01 '19 at 05:31
  • That would return the wrong version in the month(s) before a new version comes out. – ikegami Sep 01 '19 at 05:40

1 Answers1

1
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";
'
ikegami
  • 367,544
  • 15
  • 269
  • 518