http://www.perlmonks.org?node_id=980650

live4tech has asked for the wisdom of the Perl Monks concerning the following question:

I recently came upon the following line of code:

$FH = $OUTFH{$name} ||= IO::File->new(">g:\\perl_scripts\\$name.log") +or die $!;

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.

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.

Is this the same as //? This is really poorly documented...