in reply to Parsing a text file
use strict; use warnings; my $file = 'msgcount.txt'; open(LOG, '<', $file) or die "Can't read '$file': $!"; my %sum; while (<LOG>){ chomp; # remove newline my ($date, $name, $number) = split m/ /, $_; $sum{$name} += $number; } # now print the result: while (my ($name, $total) = each %sum){ print "$name\t$total\n"; }
|
|---|