<?xml version="1.0" encoding="windows-1252"?>
<node id="1008468" title="Re: How can one call the lowest value of an array by reference?" created="2012-12-12 03:05:04" updated="2012-12-12 03:05:04">
<type id="11">
note</type>
<author id="968231">
Athanasius</author>
<data>
<field name="doctext">
&lt;p&gt;Here is one way:&lt;/p&gt;

&lt;code&gt;
#! perl
use Modern::Perl;
use List::Util qw( min );

my @vals  = qw(   5   3   2  12   2 );
my @names = qw( Cat Bat Cow Dog Rat );

my $min_val = min @vals;
my @indices = grep { $vals[$_] == $min_val } (0 .. $#vals);

for (@indices)
{
    printf "Lowest value: %d, index: %d, corresponding name: %s\n",
            $min_val, $_, $names[$_];
}
&lt;/code&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;code&gt;
18:01 &gt;perl 429_SoPW.pl
Lowest value: 2, index: 2, corresponding name: Cow
Lowest value: 2, index: 4, corresponding name: Rat

18:03 &gt;
&lt;/code&gt;

&lt;p&gt;Hope that helps,&lt;/p&gt;

&lt;div class="pmsig"&gt;&lt;div class="pmsig-968231"&gt;
&lt;p&gt;
&lt;table width="100%"&gt;
&lt;tr&gt;
  &lt;td align="left"&gt;
    Athanasius&amp;emsp;&lt;font color="#008000"&gt;&amp;lt;&lt;/font&gt;[href://http://www.biblegateway.com/passage/?search=John%203:16&amp;version=NLV|&lt;font color="#008000"&gt;&amp;deg;&lt;/font&gt;]&lt;font color="#008000"&gt;(((&amp;gt;&amp;lt;&lt;/font&gt;&amp;emsp;&lt;i&gt;contra mundum&lt;/i&gt;
  &lt;/td&gt;
  &lt;td align="right"&gt;
    [href://http://translate.google.com.au/#la/en/Iustus%20alius%20egestas%20vitae%2C%20eros%20Piratica%2C|&lt;b&gt;Iustus alius egestas vitae, eros Piratica,&lt;/b&gt;]
  &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1008463</field>
<field name="parent_node">
1008463</field>
</data>
</node>
