>> Can someone explain what:
>>
>> $pi ||= 3;
>>
>> ...means? I just saw it in Programming Perl (pp 540), but it doesn't
>> explain it. Thx!
>
> || is the logical OR operator (see perldoc perlop) which says that if $pi is
> TRUE then keep the current value of $pi but if $pi is FALSE then assign 3 to
> $pi.
>
> That could also be written as:
>
> unless ( $pi ) {
> $pi = 3;
> }
Aah, I see now. Just like the following pairs of commands do equivalent
things:
$pi += 3
$pi = $pi + 3
$pi ||= 3
$pi = $pi || 3
Is there an "&&=" also? How about "or="?
(I can't think of why I'd need it, but I'm just curious if perl is
converting "<left> <anything>= <right>" to "<left> = <left> <anything>
<right>".)
Thanks!
- B
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>