in reply to Reading files, skipping very long lines...

You'll need to do your own buffering and look for newlines yourself. Read $MAX chars; if there's no newline in it (/\n/), keep reading and throwing away $MAX chars at a time until you find a newline.

If there's a newline (and you're not in the middle of throwing away a superline), print everything up to the newline, and read $MAX-(number of chars after the newline) so that you have a total of $MAX characters to look at. Repeat from the top.


Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Reading files, skipping very long lines...
by davidrw (Prior) on Sep 29, 2005 at 17:29 UTC
    If there's a newline (and you're not in the middle of throwing away a superline), print everything up to the newline,
    ... and repeat --- could have a string like "foo\nbar\nstuff\nblah blah blah blah blah" ... (see Limbic~Region's detailed post below)