Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Stuck with hw

by glivings (Scribe)
on Apr 02, 2003 at 20:33 UTC ( [id://247593]=note: print w/replies, xml ) Need Help??

in reply to Stuck with hw

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://247593]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-17 14:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found