Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Returning indices with same values for array within hash.

by AnomalousMonk (Archbishop)
on Nov 11, 2013 at 17:12 UTC ( [id://1062023]=note: print w/replies, xml ) Need Help??


in reply to Re: Returning indices with same values for array within hash.
in thread Returning indices with same values for array within hash.

... each ... newer Perl ...

Perl version 5.12+, and 5.14+ has the "highly experimental" feature of allowing each to directly take a reference:

>perl -wMstrict -le "my %matrix = (NI => [2, 1, 1, 3, 4] ); ;; my @NI_index; my $min; while (my ($i, $v) = each $matrix{NI}) { if(not defined $min or $v < $min) { $min = $v; @NI_index = (); } push @NI_index, $i if $v == $min; } print qq{@NI_index}; " 1 2

Log In?
Username:
Password:

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

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

    No recent polls found