Perl : meaning of ||= symbol

While going through the below perl code, there is a line
which contains

$sheet -> {MaxRow} ||= $sheet -> {MinRow};

Could anyone please explain the meaning of ||= and where it is used

complete code
---------------

foreach my $sheet (@{$excel -> {Worksheet}}) {
 
        printf("Sheet: %s\n", $sheet->{Name});
        
        $sheet -> {MaxRow} ||= $sheet -> {MinRow};
                 foreach my $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) {
         
                $sheet -> {MaxCol} ||= $sheet -> {MinCol};
                
                foreach my $col ($sheet -> {MinCol} ..  $sheet -> {MaxCol}) {
                
                        my $cell = $sheet -> {Cells} [$row] [$col];
 
                        if ($cell) {
                            printf("( %s , %s ) => %s\n", $row, $col, $cell -> {Val});
                        }
 
                }
 
        }

---------- Post updated at 08:17 AM ---------- Previous update was at 07:16 AM ----------

Could anyone please explain the above code( ||= )

That's logical OR assign operator.

   $sheet -> {MaxCol} ||= $sheet -> {MinCol};

probably meant that if $sheet -> {MaxCol} doesn't exists (returns false), assign the value of $sheet -> {MinCol} to this.

See perlop for more details.

Short version:
x ||= y means that if x is false, set it to y.

Long version:
||= is an assignment operator. x ||= y is the same thing as x = x || y . || is the logical-OR operation. If the first operand (x) is a true value, it is returned. If it is false, the second operand (y) is returned. This is the typical logical-OR shortcircuiting behavior seen in C and many other languages.

Regards,
Alister

---------- Post updated at 09:58 AM ---------- Previous update was at 09:56 AM ----------

Don't bump your posts unless there is new, relevant information. Or at least wait a day. If it's an urgent matter, there's an Emergency forum you can use.

Regards,
Alister