in reply to I need to sort out some values and get only the highest generated by my perl script
That is, just keep track of what the largest you've seen so far is as you're going through them, and when you reach the end, it's guaranteed to be the largest overall.my ($largest_index, $largest_value) = (-1E6, undef); #make sure $largest_index starts below the lowest possible #value you can get for my $data (@some_big_long_list){ my $this_index = index_from($data); if ($this_index > $largest_index){ $largest_index = $this_index; $largest_value = $data; } } #do something with largest data
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: I need to sort out some values and get only the highest generated by my perl script
by riffraff (Pilgrim) on Oct 29, 2004 at 15:29 UTC | |
by Eimi Metamorphoumai (Deacon) on Oct 29, 2004 at 15:52 UTC |