my ( %tally, $total ); my $logfile = open @*ARGS[0] :r err die "Couldn't open '@*ARGS[0]' for reading: $!\n"; for =$logfile -> $logline { my $daemon = $_.split()[4]; # TODO look at $_.comb()[4] # $daemon ~~ s{\[\d+\]:}={}; # boom on win32 pugs # from http://www.mail-archive.com/perl6-users@perl.org/msg00156.html $daemon ~~ s:Perl5/\[\d+\]://; %tally{$daemon}++; $total++; } $logfile.close(); # always nice to be tidy # sort with place holder vairables dones't work properly under pugs yet. # GAH # this works but reverse doesn't. for %tally.keys.sort:{ %tally{$^a} cmp %tally{$^b} } -> $daemon { my $percentage = sprintf("%02d", (%tally{$daemon} / $total) * 100); printf("%-20s => %8d (%2d%%)\n", $daemon, %tally{$daemon}, $percentage); }