use JSON qw( decode_json );
use List::MoreUtils qw( all part nsort_by );
+if (@ARGV and all { m[/] } @ARGV) {
+ say pp blizget($_) for @ARGV;
+ exit;
+}
+
my ($profiles, $clanmatches) = part { /\D/ } @ARGV; # separate numbers
-@{$profiles}
+$profiles && @{$profiles}
or die "Usage: $0 <profile id>... [<clan name>...]\n";
-my ($clanmatch) = map { $_ && qr/\A(?:$_)\z/i } join '|', @{$clanmatches};
+my ($clanmatch) = map { $_ && qr/\A(?:$_)\z/i } join '|', @{$clanmatches || []};
sub blizget {
state $bliz = do {
my %ladders = (
map { $_->{ladder}->[0]->{ladderId} => $_ } # unique
grep { $_->{ladder}->[0]->{division} }
- map { $_->{currentSeason}->@* } @ladderdata
+ map { $_->{previousSeason}->@*, $_->{currentSeason}->@* }
+ @ladderdata
);
my @ladders = (
nsort_by {