develooper Front page | perl.beginners | Postings from March 2002

Processing Large Files

Thread Next
From:
RArul
Date:
March 13, 2002 08:21
Subject:
Processing Large Files
Message ID:
78B385FB8F70D511857900B0D0D06A58890AE4@mail.newenergyassoc.com
Friends,

I need to process 300+ MB text files. I tried to open one such file; read 10
lines (line by line) and output those 10 lines to a new text file. Despite
reading line by line, it was taking a very long time for processing. Is
there anything that I can try to speed it up!!

Here is my pronto code:

###########################
#!/usr/bin/perl
use strict;
my $from	= "humongous.txt";
open(INP, $from) or die "cannot open input file $!";
open(OUT, ">sample.txt") or die "cannot open input file $!";
print("trying to read input file\n");
while(<INP>){
	print STDOUT;
	print OUT;
	last if($. >= 10);
}
close(INP);
close(OUT);
##########################


Thanks,
Rex


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About