On 3/31/06, Wagner, David --- Senior Programmer Analyst --- WGO
<[EMAIL PROTECTED]> wrote:

>         I need to handle a set of numbers where I want only the
> lowest 1000. There will be no rhyme or reason as the data comes in.

You should loop over the input, pushing each item on to an array. If
at any time you have 2000 items in the array, sort them and discard
any you don't want to keep.

    $#data = 999 if $#data > 999;        # OBperl: one way to discard elements

When you finish looping, sort-and-discard again. You'll never need
more than 2N items in memory at any given time. Does that algorithm
work for your needs?

> *******************************************************
> This message contains information that is confidential
> and proprietary to FedEx Freight or its affiliates.
> It is intended only for the recipient named and for
> the express purpose(s) described therein.
> Any other use is prohibited.
> *******************************************************

It's prohibited to mock the silly disclaimer the lawyers put at the
end of your message? Dang. I'm in trouble now.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to