open(HOST,"<$ARGV[0]");
my $i++;
my %vers;
my %done;
while(my $line=<HOST>) {
    if ($line=~/^\#/) { next; }
    my $host=(split(':',$line))[3];
    chomp($host);
    if (!$host || exists($done{$host})) { next; }
    $done{$host}=1;
    print($host." -> ");
    my $ver=`curl --max-time 15 --connect-timeout 5 -s http://$host/adm/login | grep -- -200 | tr ">" "\n" | tail -1 `;
    $ver=~s/&nbsp;//g;
    $ver=~s/ //g;
    if ($ver eq "") { print("\n"); }
    print($ver);
    $ver=~s/\s//g;
    push(@{$vers{$ver}},$host);
#    if ($i++==14) { last; }
}

foreach my $key (sort(keys(%vers))) {
    print($key." -> \n");
    print("     ".join("\n     ",@{$vers{$key}})."\n");
}
