
Admin
Deleted
Apr 16, 2000, 7:35 PM
Post #2 of 3
(406 views)
|
The answer depends on how you read the data into your program... If you slurp the entire file into an array or hash, that will start slowing down pretty quickly, depending on your server's resources. Tossing the contents into hashes will generally slow down the program more than arrays. The best way to handle large files is to not slurp it anywhere -- handle each line one at a time. For example: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> open (FILE, "<file.txt") or die "Couldn't open file.txt $!"; while (<FILE> ){ chomp; my @whatever = split(/\t/,$_); } close FILE; </pre><HR></BLOCKQUOTE> Essentially, you will read the file line by line. Because Perl cleans up after itself, the previous line will "go out of scope" when the next line is read, and memory resources that was used by the previous line will be freed. Hope this helps!
|