Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-04-12 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found