Interesting problem and discussion. I have little to add to what has already been said, but wanted to note that a solution to the problem of finding the index of the minimum in an array is conveniently implemented in Perl Data Language (PDL) with the minimum_ind function.

From the manual:
Module PDL::Ufunc minimum_ind Signature: (a(n); indx [o] c()) Like minimum but returns the index rather than the value Output is set bad if all elements of the input are bad, otherwise +the bad flag is cleared for the output piddle.
So, in principle, assumming you already have an array @array you could do:
use PDL; my $piddle = pdl @array; my $index_minimum = minimum_ind $piddle; say $index_minimum;

You could try to reduce your problem so you can use a minimum_ind approach, for example, if you have negative numbers you could convert them to NaN or take abs and make them positive, whatever is important or relevant in your context.


In reply to Re: How to get the index of smallest whole number in an array? by hda
in thread How to get the index of smallest whole number in an array? by sohamsg90

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.