in reply to Trying to read a filehandle inside a loop
while (my $foo = <BAR>) { # use $foo } [download]
is also much more idiomatic, which makes your code more readable to other perl programmers.