in reply to extracting corresponding values from another array
#!/usr/bin/perl -w use strict; my @temps = ('69', '70', '71'); my @numbers = ('0.115', '3.667', '4.78'); my $counter=0; my $index=0; my $largest=shift @numbers; for (@numbers){ $index = $counter if ($temps[$counter++]>$largest); } print $temps[$index];
#!/usr/bin/perl -w use strict; my @temps = ('69', '70', '71'); my @numbers = ('0.115', '3.667', '4.78'); my $index=0; my $largest=$numbers[0]; for (1 .. $#numbers) { if ($numbers[$_] > $largest){ $largest=$numbers[$_]; $index=$_; } } print $temps[$index];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: extracting corresponding values from another array
by Jaap (Curate) on Dec 03, 2002 at 12:20 UTC | |
by demerphq (Chancellor) on Dec 03, 2002 at 12:34 UTC | |
by Abigail-II (Bishop) on Dec 03, 2002 at 13:09 UTC | |
by demerphq (Chancellor) on Dec 03, 2002 at 15:26 UTC | |
by Abigail-II (Bishop) on Dec 03, 2002 at 16:40 UTC | |
| |
|
Re: Re: extracting corresponding values from another array
by demerphq (Chancellor) on Dec 03, 2002 at 12:36 UTC |