Brainteaser (help!)
Oliver Gorwits
oliver.gorwits at oucs.ox.ac.uk
Wed Mar 14 09:39:37 PDT 2007
Lee Larcombe wrote:
> @arrayG = qw (1.048 0.657 0.437 2.363 1.964 0.787 1.078 0.686);
>
> I need to know the array position of the largest number, ie 2.363 is
> largest, but I need to return $arrayG[3] - the '3' is what I need.
Try a combination of max() from List::Util (ships with Perl) and then
first_index() from List::MoreUtils (on the CPAN).
regards,
oliver.
--
Oliver Gorwits, Network Infrastructure Group,
Oxford University Computing Services
More information about the MiltonKeynes-pm
mailing list