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
True laziness is hard work

In reply to Re^3: Aaaarghh...hashes of hashes..again :( by GrandFather
in thread Aaaarghh...hashes of hashes..again :( by viffer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.