in reply to Re: Re: Trying to read a filehandle inside a loop
in thread Trying to read a filehandle inside a loop

Why doesn't the 'while' loop slurp the data too?
Because the filehandle is only evaulated in a scalar context, so you'll only get one line per iteration. Whereas a foreach loop evaluates the filehandle in a list context which produces the list which it iterates over. Another thing to be aware of is that if you're iterating over a filehandle in a while loop perl will auto-magically stick a defined test around your condition e.g
while(my $line = <DATA>) # becomes while (defined(my $line = <DATA>))
So now if a single 0 is read the loop will continue.
HTH

_________
broquaint