#!/usr/bin/perl -s

use v5.12;
use strict;
use warnings;

use HTTP::Tiny;

our ($full);

my $content = HTTP::Tiny->new->get("https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/");

die "FAILED!" unless $content->{success};

$content = $content->{content};

my $max = 3;
my $maxstr = "";

while ($content =~ /firefox-(\d+\.\d+(?:[a-z]\d+)?)/g) {
    my $v = $1;
    my $decimal = 0;
    $v =~ /^(\d+)/ and $decimal = $1;
    if ($decimal > $max) {
        $max = $decimal;
        $maxstr = $v;
    }
}

if ($full) {
    say "$maxstr"
} else {
    say "$max.*"
}
