Think about Loose Coupling | |
PerlMonks |
Re: min and mindexby Kenosis (Priest) |
on Nov 06, 2012 at 17:37 UTC ( [id://1002538]=note: print w/replies, xml ) | Need Help?? |
Given your one-to-one mapping between the two arrays (i.e., the same number of elements) and the numbers in @array1 are not repeated, consider the following:
Output:
Two hashes are created. The first (%array1Hash) pairs each element of @array1 with its position in the array. The second (%hash) pairs the elements of @array1 as the keys with the elements of @array2 as values. When you've found the minimum value in @array1, you can use it as the key to get the associated value from @array2. Hope this helps! Update: Added printing the min val of @array1 and that element's position in the array.
In Section
Seekers of Perl Wisdom
|
|