in reply to Re^5: nested <FILE> read returns undefined?
in thread nested <FILE> read returns undefined?

just to bring closure on this-- I wasn't necessarily trying to argue that there was a "right way" or "wrong way" so much as saying that there is ambiguity about whether for $scalar (@array) would cause <FILE> to be read in its entirety, or line-by-line. there are many cases where perl looks at lvalue to determine what to do on the right side, and this seems like just such a case at first blush.

$line = <FILE>; # reads one line from FILE; @lines = <FILE>; # slurps up the whole thing. for $line (<FILE>) ... # which of the above applies?

The thing that really makes the visual assessment ambiguous is the placement of $line in the for statement, which is the source of the perceived ambiguity. Granted, I only saw it as the scalar form, and I do realize that it'd be more like saying

for $line (@lines)

which clarifies how perl is reading it (and thus, what happens with <FILE>), but seeing both ways now makes the ambiguity more understandable.