in reply to Re: How does the while works in case of Filehandle when reading a gigantic file in Perl
in thread How does the while works in case of Filehandle when reading a gigantic file in Perl
Opening a file is timewise an "expensive" operation. As the file is opened for appending new lines to it, opening the file will take longer and longer, since the OS has to find the end of file to add the new line to it.
Solution: open the output file in the beginning of your script and close it at the end. You should see an immediate speed improvement.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How does the while works in case of Filehandle when reading a gigantic file in Perl
by raj4489 (Acolyte) on Feb 06, 2015 at 12:36 UTC | |
by CountZero (Bishop) on Feb 06, 2015 at 19:45 UTC |