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"; }
In reply to Re: Parsing a text file
by moritz
in thread Parsing a text file
by nimajneb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |