On Wed, 10 Mar 2010 10:49:16 +0100, Dr.Ruud wrote:

> Jeff Peng wrote:
> 
>> so how about while (my $line = <FILE>) instead of using $_?
> 
> Evil! An empty line, or a line with only a "0" in it.

Not so:

$ perl -MO=Deparse -e 'while(my $l=<F>) {}'
while (defined(my $l = <F>)) {
    do {
        ()
    };
}
-e syntax OK

What's interesting to me is that Perl sticks a 'do' in there that you 
don't get with <>:

$ perl -MO=Deparse -e 'while(<>) {}'
while (defined($_ = <ARGV>)) {
    ();
}
-e syntax OK

-- 
Peter Scott
http://www.perlmedic.com/     http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl1/

-- 
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