#!/usr/bin/perl use strict; use warnings; use Text::CSV; use constant APP => 1; use constant CPU => 2; my $file = $ARGV[0] or die "Usage: $0 "; open(my $fh, '<', $file) or die "Unable to open '$file' for reading: $!"; <$fh>; # Throw away header my $csv = Text::CSV->new(); my %data; while (<$fh>) { chomp; if ($csv->parse($_)) { my @field = $csv->fields; $data{$field[APP]} += $field[CPU]; } else { warn "parse() failed on '$_'\n"; } } for my $app (keys %data) { print "$app\t$data{$app}\n"; }