On 4/9/12 Mon  Apr 9, 2012  12:22 PM, "Tiago Hori" <tiago.h...@gmail.com>
scribbled:

> Hey Jim,
> 
> Makes perfect sense now. Thanks.
> 
> Just so I make sure I understand it correctly: So every time I use a while
> (<FILEHANDLE>) loop each line of input from the file gets assigned to $_ in
> each iteration of the loop?

Almost.

<> is an operator. Each time <FILEHANDLE> is evaluated, a line is read from
the file and assigned to the $_ variable. This is regardless of whether or
not <FILEHANDLE> appears in the condition of a while statement.

>From 'perldoc perlop' (search for "I/O Operators"):

"In scalar context, evaluating a filehandle in angle brackets yields the
next line from that file (the newline, if any, included), or "undef" at
end-of-file or on error.  When $/ is set to "undef" (sometimes known as
file-slurp mode) and the file is empty, it returns '' the first time,
followed by "undef" subsequently."
 




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to