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 DeltronicsIn reply to Re^2: How does the while works in case of Filehandle when reading a gigantic file in Perl
by CountZero
in thread How does the while works in case of Filehandle when reading a gigantic file in Perl
by raj4489
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |