Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: max key-value pair in a hash

by kettle (Beadle)
on Mar 27, 2006 at 06:26 UTC ( [id://539373]=note: print w/replies, xml ) Need Help??


in reply to Re: max key-value pair in a hash
in thread max key-value pair in a hash

thanks for the replies! all very helpful. I think that this last was what I was most curious about though - how to print the key, given the value. but what happens where there are two keys that share the same value? and what is the 'l' option in the shebang ??

Replies are listed 'Best First'.
Re^3: max key-value pair in a hash
by BrowserUk (Patriarch) on Mar 27, 2006 at 06:39 UTC
    but what happens where there are two keys that share the same value?

    You'll get the weather associated with one of the maximal values--which one is determined by the hashing algorithm and the text of the keys.

    This is exactly the same effect as with your sort sort method.

    and what is the 'l' option in the shebang ??

    It sets $/ & $\ (INPUT and OUTPUT SEPARATORS) to \n. It just saves having to type  . "\n"; each time. One downside is that if you use a module that uses "\n" explicitly when printing stuff, it ends up double spaced, but it's useful for standalone scripts.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found