Another variation, also on the shoulders of others:
Using an intermediate 'convenience' variable
    my $array_ref = $matrix{NI};
to hold the reference of interest can greatly simplify/clarify matters. It doesn't buy you much in this particular case, but can be very helpful with complex, deeply nested data structures.

>perl -wMstrict -le "use List::Util qw(min); use List::MoreUtils qw(indexes); ;; my %matrix = ( NI => [ 1, 5, 1, 3, 4 ] ); ;; my @indices = do { my $array_ref = $matrix{NI}; my $mat_min = min @$array_ref; indexes { $_ == $mat_min } @$array_ref; }; print qq{(@indices)}; " (0 2)

Update: And, of course, the guts of a  do { ... } block can usually be easily lifted out and plunked down in a subroutine:

>perl -wMstrict -le "use List::Util qw(min); use List::MoreUtils qw(indexes); ;; my %matrix = ( foo => { bar => [ 'oops', { NI => [ 1, 5, 1, 3, 4 ], }, ], }, ); ;; my @indices = get_indices($matrix{foo}{bar}[1]{NI}); print qq{(@indices)}; ;; sub get_indices { my ($ar) = @_; ;; my $mat_min = min @$ar; return indexes { $_ == $mat_min } @$ar; } " (0 2)

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.