summaryrefslogtreecommitdiffstats
path: root/bin/mirror-stats.pl
blob: 601a4cc1c0357c876bd0319fdd5dfc7bea1817b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl
use warnings;
use strict;
use JSON;
use WWW::Mechanize;
use Data::Dumper;

my $m = WWW::Mechanize->new();

#$m->get("https://www.archlinux.org/mirrors/status/tier/1/json");
$m->get("https://www.archlinux.org/mirrors/status/json");
my $mirrors = decode_json($m->content());

my %countries = ();

for my $mirror (@{$mirrors->{urls}}) {
	$countries{$mirror->{country_code}}++;
}

my @sorted_countries = sort {$countries{$a} <=> $countries{$b}} keys %countries;

for my $key (@sorted_countries) {
	my $value = $countries{$key};
	print "$key: $value\n";
}