in reply to Re^3: 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
The program repeatedly opens the output file for appending a new line to it. That means that the OS must somehow find the end of the file and whereas that perhaps does not necessarily mean the OS has to "slurp" the whole file, it will have to walk the chain of disk-space to find where is the end of the file, then read the last few sectors in its buffer, append the new line and write out the buffer to disk again (either immediately or upon closing the file). And all this is done for each line added since the program opens and closes the output file for each new line.
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^5: How does the while works in case of Filehandle when reading a gigantic file in Perl
by locked_user sundialsvc4 (Abbot) on Jan 30, 2015 at 22:14 UTC |