#!/usr/bin/perl use strict; use warnings; my %STAT; while (<>) { my ($stamp, $acc, $src, $dst, $tclass, $XXX, $pkt, $port, $bytes) = split; next unless $tclass == 10; my $entry = $STAT{$src}; if (not defined $entry) { $entry = { 'count' => 0, 'packets' => 0, 'bytes' => 0 } } $entry->{'count'}++; $entry->{'packets'} += $pkt; $entry->{'bytes'} += $bytes; $STAT{$src} = $entry; } foreach my $src(sort { -($STAT{$a}->{'bytes'} <=> $STAT{$b}->{'bytes'}) } keys %STAT) { my $entry = $STAT{$src}; print "$src $entry->{'count'} $entry->{'packets'} $entry->{'bytes'}\n"; }