in reply to logical-assignment operators
When you have an operator paired with an =, that can usually be translated to an easier to understand version. Your examples could be written as:
$v ||= $w --> $v = $v || $w $x &&= &y --> $x = $x && $y $v |= $w --> $v = $v | $w $x &= $y --> $x = $x & $y
The first set of examples are logical and, and logical or. The or example checks if $v is true, if it is, $v is set to itself, OR it is set to $w. The and example is a little more confusing and I'm not really sure why you would want to use it. If $x is 0, it remains 0, otherwise it is set to $y.
The second set of examples is bitwise and, and bitwise or.
You can look up more information about these operators in perlop
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: logical-assignment operators
by Marshall (Canon) on Mar 27, 2009 at 19:40 UTC | |
|
Re^2: logical-assignment operators
by gwadej (Chaplain) on Mar 27, 2009 at 19:15 UTC | |
|
Re^2: logical-assignment operators
by Marshall (Canon) on Mar 27, 2009 at 19:24 UTC |