At 7:37 AM -0400 6/11/2002, Erik Price wrote:

>> >If you are determined to do it in Perl, then slurp all of the
>> >lines into an array and print @array[$i-N .. $i+M].
>>
>> If your file is HUGE you may not want to do this.  Instead, keep
>> a rotating buffer array of N+M+1 lines.  With each new line,

>How do you "discard" an array element in Perl, for the sake of
>conserving memory?
>In other words, would someone mind providing the code for the above
>line-slurping technique?

I means simply using push() to add a line to the end of the
array, and at the same time using shift() to remove the
first array element.   The shifted-off string will be
garbage-collected if there are no other references to it.

--
Ron Newman      [EMAIL PROTECTED]
http://www2.thecia.net/users/rnewman/


Reply via email to