Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Reading a huge input line in parts

by kroach (Pilgrim)
on May 04, 2015 at 15:59 UTC ( #1125587=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1125587]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2020-10-29 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (266 votes). Check out past polls.

    Notices?