in reply to Re: Reading a huge input line in parts
in thread Reading a huge input line in parts

The last number is not read unless eof is encountered. I can't undo the setting of $/ and read again because I have no way of detecting the last number. If I undo it midway I would get the rest of the line, which could be enormous.
  • Comment on Re^2: Reading a huge input line in parts

Replies are listed 'Best First'.
Re^3: Reading a huge input line in parts
by hdb (Monsignor) on May 04, 2015 at 16:11 UTC

    I cannot reproduce your problem but I was thinking of

    use strict; use warnings; sub do_something { print '{', $_[0], "}\n" } { local $/ = ' '; while (<>) { do_something($_); } } do_something(<>);
Re^3: Reading a huge input line in parts
by Laurent_R (Canon) on May 04, 2015 at 17:58 UTC
    It should not be to costly in terms of resources and performance to check if you have a space at the beginning and at the end of each chunk of data before splitting it, and reconstruct the boundary numbers accordingly, especially if your read data chunks are relatively large.

    Update: Ooops, this was meant as an answer to the following post: Re^2: Reading a huge input line in parts, sorry for inconvenience.

    Je suis Charlie.