<?xml version="1.0" encoding="windows-1252"?>
<node id="1004313" title="Re: shift and logical or" created="2012-11-17 08:46:06" updated="2012-11-17 08:46:06">
<type id="11">
note</type>
<author id="840762">
rjt</author>
<data>
<field name="doctext">
&lt;p&gt;Good replies so far, so I won't steal anyone's monastic thunder, although I'll add that Perls &gt;= 5.10 have the [doc://perlop#Logical-Defined-Or|logical defined-or operator], &lt;c&gt;//&lt;/c&gt;. Often this is what you really want, but since there is a lot of code in the wild that pre-dates it, you may notice disproportionate use of &lt;c&gt;||&lt;/c&gt;.&lt;/p&gt;

&lt;p&gt;The difference is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use &lt;c&gt;$a //= 'foo';&lt;/c&gt; when you want to assign 'foo' to $a if $a is not [doc://defined].&lt;/li&gt;
&lt;li&gt;Use &lt;c&gt;$a ||= 'foo';&lt;/c&gt; when you want to assign 'foo' to $a if $a has a false value, such as zero or an empty string.&lt;/li&gt;
&lt;/ol&gt;</field>
<field name="root_node">
1004257</field>
<field name="parent_node">
1004257</field>
</data>
</node>
