On Thu, 29 May 2003 10:47:26 -0500, [EMAIL PROTECTED] (Camilo
Gonzalez) wrote:
>I need to read in from a temp file that is about 10 megs big in 1.5 meg
>increments and write results to a database. I can't slurp up the whole
>temp file because I'm only allowed 2 megs of memory. I was hoping to
>read in only 1.5 megs per pass of the file but the read seems to be
>slurping up the whole thing. Do I need sysread?
(this type of question belongs in perl.beginners)
while (sysread FILE, my $data, $chunksize){ ..... };
An alternative to using sysread would be to use Tie::File, and only
bring a limited number of lines into play at a time.
use Tie::File;
my @content;
tie (@content, 'Tie::File', $file)
or die "Error: couldn't tie $file: $!\n";
# .... and treat the filecontent like an array, e.g.
print scalar(@content);
# .....
untie (@content);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]