#!/usr/bin/perl
$langset=0;
while (<>) {
    if ($langset) {
	if (/teamerror\">([0-9]{1,3}\.[0-9]{2})%<\/font>/) {
	    $number++;
	    $percent=$1;
	    if ($number==3) { # we're looking for the third occurence of this same string
		$percentages{$langset}=$percent;
		if ($percent>=80.0) {
		    $support{$langset}=$percent;
		} elsif ($percent>=50.0) {
		    $part{$langset}=$percent;
		} else {
		    $unsup{$langset}=$percent;
		}
		$langset=0;
		$number=0;
	    }
	}
    } elsif (/<a .*>([A-Za-z ]+)\(([^)]+)\)<\/a>/) {
	$langset=$2;
	$fullnames{$langset}=$1;
	$number=0;
    }
}

print "Supported languages (over 80%):\n\n";
foreach $lang (sort { $support{$b} <=> $support{$a} || $a cmp $b } keys %support) {
    getlangline($lang);
}
print "\n\n";

print "Partially supported (over 50%, less than 80%):\n\n";
foreach $lang (sort { $part{$b} <=> $part{$a} } keys %part) {
    getlangline($lang);
}
print "\n\n";


print "Unsupported languages (less than 50%):\n\n";
foreach $lang (sort { $unsup{$b} <=> $unsup{$a} } keys %unsup) {
    getlangline($lang);
}
print "\n\n";

sub getlangline($lang) {
    $lang=$_[0];
    $fullname=$fullnames{$lang};
    printf "      %-10s%-34s  %6.2f%%\n", $lang,$fullname,$percentages{$lang};
}
