I use somewhat large files in perl (most under 1 megabyte but over 
100K) and I've never had a memory problem (fingers crossed), but I am 
wondering about using some rotating buffer techniques for when these 
data files start to get larger.  What is the proper method for taking 
a file of say 10,000 lines, and slurping up just lines 2,200 to 2,300 
???

Jim

At 7:57 AM -0400 6/11/02, Ron Newman wrote:
>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/


-- 
The Kanji Way to Japanese Language Power
http://www.rolomail.com/cgi-bin/sanadd.pl?1-0-136

Reply via email to