#!/usr/bin/env xsh
quiet;
# open --format html 'cpan.html';
open --format html 'http://www.cs.uu.nl/people/henkp/mirmon/cpan.html';
perl { $country = @ARGV ? shift(@ARGV) : 'us' };
for //tr[th/a/@name = $country]/following-sibling::* {
if th/a/@name last;
$url = (td[1]/a[1]/@href);
$time = (td[3]);
perl { $time{$url} = $time };
}
perl {
for (values %time) {
s{([\d.]+) days?}{$1 * 24}e
or s{([\d.]+) hours?}{$1}
or s{([\d.]+) minutes?}{sprintf "%.1f", $1 / 60}e
or die "Don't understand $_";
}
for (sort { $time{$a} <=> $time{$b} } keys %time) {
print "$_ => $time{$_}\n";
}
}