http://qs1969.pair.com?node_id=11137449


in reply to Re^2: Splitting in while loop
in thread Splitting in while loop

while (my $line = <>) ... Similarly, ... while (my $item = pop @my_array)
use warnings; use strict; while (my $line = <DATA>) { chomp $line; print "<$line>\n"; } my @array = ("Foo","0","Bar"); while (my $item = pop @array) { print "[$item]\n"; } __DATA__ Hello 0 World

Outputs:

<Hello> <0> <> <World> [Bar]

I'd call that a pretty serious caveat. As per I/O Operators, the first is equivalent to while ( defined( my $line = <> ) ), and readline returns undef at EOF, while the second one will stop at any false value, and arrays can contain undefs too.