#!/usr/bin/perl -w
use strict;
use warnings;
use File::Basename;

my ( %tally, $total );

die basename $0 . " [-p] <files>\n" unless @ARGV == 1;

while (<ARGV>) {
  my $daemon = (split)[4];
  $daemon =~ s!\[\d+\]:$!!;
  $tally{$daemon}++;
  $total++;
}

for my $daemon ( sort { $tally{$b} <=> $tally{$a} } keys %tally ) {
  my $percentage = sprintf("%02d", ($tally{$daemon} / $total) * 100);
  printf("%-20s => %8d (%2d%%)\n", $daemon, $tally{$daemon}, $percentage);
}
