I'm assuming that the part youre having a problem with is printing out the reverse-sorted output, in which case the following is probably what you want, instead of your 5 print statements at the end:

foreach (sort { $player{$b}[1]*1 + $player{$b}[3]*.5 <=> $player{$a}[1 +]*1 + $player{$a}[3]*.5 } keys %player) { print $_ . " " . join(" ", @{$player{$_}}[1..3]) . "\n"; }

this substitution results in the following output:
this results in Kasparov 2 1 2 karpov 2 1 1 BlueJunior 1 2 2 Anand 1 2 0 Shirov 1 1 0 Karpov 1 0 0

Also something you should look out for is unnecessary duplication, specifically in lines like this:
$player{$1} = [ $1, $p1wins, $p1loss, $p1draw ];

Is there a reason you need to duplicate the player's name? That information is already stored as the key, you don't need it in the array.

These are just some quick pointers to help you on your way... it's 4:30, and I'm going home.

Also: use <CODE></CODE> tags - you'll find that people are more willing to help if they can actually look at your unmangled code - Writeup Formatting Tips


In reply to Re: Stuck with hw by glivings
in thread Stuck with hw by dirtyboy

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.