in reply to Returning indices with same values for array within hash.
Or is there another way to do it?
More of a variation on a theme (which builds on the previous answers):
use strict; use warnings; use List::Util qw( min ); use List::MoreUtils qw( indexes ); my %matrix = ( NI => [1, 5, 1, 3, 4] ); my $minimum = min @{ $matrix{NI} }; my @indices = indexes { $_ == $minimum } @{ $matrix{NI} }; print "@indices";
Output:
1:57 >perl 774_SoPW.pl 0 2 1:57 >
See List::MoreUtils.
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
In Section
Seekers of Perl Wisdom