Chas. Owens wrote:
On Fri, Aug 7, 2009 at 18:42, Admin<ad...@enabled.com> wrote:
Shawn H. Corey wrote:
Admin wrote:
Hi there,

is there a page that explains the ||= operator and similar operators?
google is not quite finding the special characters in the first 10 hits.


See http://perldoc.perl.org/perlop.html#Assignment-Operators



thanks Shawn But I searched the page and there is nothing discussing ||=
snip

from perldoc perlop
       Assignment Operators

       "=" is the ordinary assignment operator.

       Assignment operators work as in C.  That is,

           $a += 2;

       is equivalent to

           $a = $a + 2;

       although without duplicating any side effects that dereferencing the
       lvalue might trigger, such as from tie().  Other assignment operators
       work similarly.  The following are recognized:

           **=    +=    *=    &=    <<=    &&=
                  −=    /=    |=    >>=    ||=
                  .=    %=    ^=           //=
                        x=

       Although these are grouped by family, they all have the precedence of
       assignment.

Perhaps you are confused by what

$a = $a || 2;

does?  In that case look at the [section of perldoc perlop that deals
with the || operator][1]:

       C−style Logical Or

       Binary "||" performs a short‐circuit logical OR operation.  That is, if
       the left operand is true, the right operand is not even evaluated.
       Scalar or list context propagates down to the right operand if it is
       evaluated.

[1] : http://perldoc.perl.org/perlop.html#C-style-Logical-Or


Okay Chas,

we all found that in the docs. based on the information you posted. what does "||=" do?

Cheers,

Noah


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