You could just read one char at a time, looking for a newline to terminate the line. You can use
read for that, or
local $/=\1;. Assuming you have not switched buffering off, the data will not be transferred from the disc one char at a time, only from the buffer. It is then easy to impose a limit for a line length.