-
Notifications
You must be signed in to change notification settings - Fork 0
/
summarize.pl
40 lines (35 loc) · 1.11 KB
/
summarize.pl
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use 5.20.0;
use utf8;
use open ":encoding(utf8)";
use IO::Dir;
use IO::File;
use IO::All;
use File::Spec::Functions qw/catfile/;
use JSON::XS;
require "./config.pl";
our %version;
my $results_dir = "results";
my $summarize_file = "results.json";
my $obj = {
version => {},
result => {},
};
my $dh = new IO::Dir($results_dir) or die "cannot open dir $results_dir";
while (my $category = $dh->read) {
next if $category =~ /^\./;
my $category_dir = catfile $results_dir, $category;
my $dh2 = new IO::Dir($category_dir) or die "cannot open dir $category_dir";
while (my $language = $dh2->read) {
next if $language =~ /^\./;
my $language_file = catfile $category_dir, $language;
my $time = int io($language_file)->utf8->all;
$obj->{result}->{$category} = {} unless $obj->{result}->{$category};
$obj->{result}->{$category}->{$language} = $time;
}
}
for my $language (keys %version) {
$obj->{version}->{$language} = $version{$language}->();
}
my $fh = new IO::File($summarize_file, "w") or die $!;
print $fh JSON::XS->new->utf8->pretty->encode($obj);
$fh->close;