Jenda Krynicky wrote:

But of course this does not print anything. The shift(@a) returns the first element of @a which is zero, assigns that to $i and then checks whether it's true. And of course it's not. So it skips the body and leaves the loop. Keep in mind that the value of

   my $i = shift @a

is NOT a true/false whether there was something shifted from the array. It's the value that was removed from the array and assigned to the $i. And if that value it false (undef, 0, 0.0, "0", "0.0", "" - if I remember rigth) then the whole expression evaluates to false in boolean context.

"0.0" is true:

$ perl -le'
for ( undef, 0, 0.0, "0", "0.0", "" ) {
    print $_ ? "TRUE" : "FALSE";
    }
'
FALSE
FALSE
FALSE
FALSE
TRUE
FALSE




John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

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