<>
is patient when it appears in scalar context; it reads just one line. If there is something to read, you get a string that is that line; otherwise, you get undef
. Really it reads one record, i.e., it stops after the input record separator: the value in $/
, if any (see perldoc -v '$/'
). If $/
is undef
then <>
"slurps" all input, as in that case there's just one record, but it's still reading just "one thing" in the sense of the scalar/list distinction.