Then after reading your documentation, it looks like you want to avoid this because the newline may be so far away that you fill up all your memory. In fact, it appears that you want to continue reading the line and not start on the next one. Most of the time, people would just say to do:while ( <FOO> ) { $_ = substr($_, 0, 1024); # other stuff }
But your module adds one "feature". If the value of $/ and the time new was called is found in the buffer, only the portion up to that is returned and the remainder is left in the buffer for susequent calls.{ local $/ = \1024; while ( <FOO> ) { # stuff } } # or sysread FOO, $_, 1024; # keeping track of offset
So instead of getting consistent results I may get 1024 bytes or 1 byte depending on where things fell? Doesn't seem like a very useful module to me but I could be way out in left field here. The reason sysread passes the scalar to store the results as one of the parameters is so that it can return the actual number of bytes read (0 if eof and undef if error).
Cheers - L~R
In reply to Re: Read a line up to a maximum length
by Limbic~Region
in thread Read a line up to a maximum length
by robmueller
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |