[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Read Speed



When I use open(IN) ... and while (<IN>), the 200mhz 604 that I get to use
for a little while =) reads in 1000 lines every 2 minutes- that seems
REALLY slow to me (I've got 300,000 records to get in every time I test
this program). When I use the read() command on a 5 mb file, even before
it's finished reading it, I get an out of memory error. Macperl has 20mb of
RAM, and the "about this computer..." dialog shows it using half. Here's
the script. Any idea what's up? (the file's 4.7 mb)

#!perl
print "Reading data... ";
for $i (0 .. $#ARGV) {
	open (IN, "$ARGV[$i]") || next;
	read (IN,$data,5120000); # reads up to 5mb
	close IN;
}
print "done.\n";

open (OUT, ">nodup.tab");
@data = split/\n/,$data;

until ($#data < 0) {
	$line = pop( @data );
	if ($line eq "") { print "skipped.\n"; next; }
	$data =~ s/$line//;
	@data = split/\n/,$data;
	chomp ($line = $line);
	print OUT "$line\n";
	print "$line\n";
}

close OUT;
close CONSOLE;

My system's memory is at its limit in the dialog. That couldn't cause this,
could it? (It just grabs more memory when it needs it, right?)

- Strider



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch