in reply to Re: Replace new line with white space
in thread Replace new line with white space

Hi Man, great idea :) but I need to read the text from large number of huge files, so reading line by line may be not efficient.
  • Comment on Re^2: Replace new line with white space

Replies are listed 'Best First'.
Re^3: Replace new line with white space
by Laurent_R (Canon) on Mar 10, 2014 at 22:21 UTC
    You probably don't have to worry about that. While your program may be reading line by line (presumably because that is what you need to do in your algorithm), behind the scenes, Perl is actually buffering input and reading larger chunks of data from the disk (possibly 4 or 8 kB at a time, depending on your OS, hardware, etc.). In brief, there is almost no penalty in reading your file line by line. I am using daily Perl programs to read GB or even dozens of GB of data, if it makes sense in the functional context to read data line by line, then just do it.
Re^3: Replace new line with white space
by llancet (Friar) on Mar 14, 2014 at 01:04 UTC
    No, it won't affect efficiency. Although you attempt to "read" line by line, the underlying library is actually reading block by block, and the <> operator parses the line and give you one line each time.