Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use List::Util 'sum';
- local $\ = "\n";
- local $, = "\n";
- my $STRUCTURE;
- my @FEEDS = sort { $a <=> $b } keys %{{map { map { $_ => 1 } map { keys %{$_->{'feeds'}} } values %$_ } @$STRUCTURE}};
- print
- map {
- my $d=$_;
- map {
- my $a=$_;
- T('stat', {'date' => $d},
- T('feeds', undef,
- map {
- my $f=$_;
- T('feed', {'id' => $f},
- map { my $t=$_; T($t, undef, sum map { $_->{$t} } map { $_->{$f} } map { $_->{'feeds'} } @$a) } 'request', 'click', 'error'
- )
- } @FEEDS
- ),
- T('total', undef,
- map { my $t=$_; T($t, undef, sum map { $_->{$t} } map { $_->{'total'} } @$a) } 'request', 'click'
- ),
- )
- } [
- map { $_->{$d} || () } @$STRUCTURE
- ]
- }
- sort keys %{{map { map { $_ => 1 } keys %$_ } @$STRUCTURE}};
- sub T {
- my ($name, $attr) = (shift, shift);
- map { @_ ? ("<$_>", @_, "") : "<$_/>" }
- join ' ', $name, map { qq{$_="$attr->{$_}"} } keys %$attr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement