<?xml version="1.0" encoding="windows-1252"?>
<node id="980650" title="||= (poorly documented?)" created="2012-07-09 01:43:39" updated="2012-07-09 01:43:39">
<type id="115">
perlquestion</type>
<author id="970633">
live4tech</author>
<data>
<field name="doctext">
&lt;p&gt;I recently came upon the following line of code:&lt;/p&gt;
&lt;code&gt;
$FH = $OUTFH{$name} ||= IO::File-&gt;new("&gt;g:\\perl_scripts\\$name.log") or die $!;

&lt;/code&gt;

&lt;p&gt;I have looked for the ||= operator and found it only in a table in perlop. There is no description of it or examples using it. I have not found it anywhere else. &lt;/p&gt;
&lt;p&gt;From the context of the above code line and through some testing I found that the line works like this:
$FH will be set to $OUTFH{$name} if $OUTFH{$name} is defined. If $OUTFH{$name} is undefined, $FH is set to the IO::File reference.&lt;/p&gt;

&lt;p&gt;Is this the same as //? This is really poorly documented...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
</field>
</data>
</node>
