Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Max value

by Athanasius (Archbishop)
on Apr 16, 2019 at 15:19 UTC ( [id://1232672]=note: print w/replies, xml ) Need Help??


in reply to Max value

In the spirit of TMTOWTDI:

use strict; use warnings; my %hash_name = (a => 1, b => 2, c => 3); my ($max_key, $max_value) = each %hash_name; while (my ($key, $value) = each %hash_name) { if ($value > $max_value) { $max_key = $key; $max_value = $value; } } printf "Max value is %d, which corresponds to key %s\n", $max_value, $ +max_key;

Output:

1:13 >perl 1994_SoPW.pl Max value is 3, which corresponds to key c 1:18 >

See each.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found