If I understand what you want then the following may help:
use strict; use warnings; my %totals; while (defined(my $line = <DATA>)) { chomp $line; my ($game, $first, $second, $third, $dates) = split /,/, $line; $totals{$game}{$first} += 3; $totals{$game}{$second} += 2; $totals{$game}{$third} += 1; } printResults($_, $totals{$_}) for sort keys %totals; sub printResults { my ($gameName, $gameTotals) = @_; my %byTotal; push @{$byTotal{$gameTotals->{$_}}}, $_ for keys %$gameTotals; my @scores = sort {$b <=> $a} keys %byTotal; my @place = qw{first second third}; @scores = grep {defined} @scores[0 .. 2]; print "Results for $gameName\n"; for my $score (@scores) { print "$place[0] with $score points: ", join(', ', @{$byTotal{ +$score}}), "\n"; shift @place; } print "\n"; } __DATA__ 01,01,02,03,23/03/2011 12:27:41 01,03,05,08,23/03/2011 12:37:41 01,02,05,07,23/03/2011 12:47:41 01,03,02,03,23/03/2011 12:57:41 01,01,06,08,23/03/2011 12:67:41 02,01,02,03,24/03/2011 12:27:41 02,08,05,08,24/03/2011 12:37:41 02,02,05,07,24/03/2011 12:47:41 02,03,02,03,24/03/2011 12:57:41 02,09,06,08,24/03/2011 12:67:41
Prints:
Results for 01 first with 8 points: 03 second with 7 points: 02 third with 6 points: 01 Results for 02 first with 7 points: 02 second with 5 points: 08, 03 third with 4 points: 05
In reply to Re^3: Aaaarghh...hashes of hashes..again :(
by GrandFather
in thread Aaaarghh...hashes of hashes..again :(
by viffer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |