What does the operator ||=
do in perl?
to be more specific if you have a code like:
my ($my_link);
$my_link ||= DownloadF($file,\'l\') if
Perl supports lots of assignment operators. ||=
is just a logical or
(complete with shortcircuit,) assignment.
So essentially what you're looking at is:
if ($s->{_l}) {
$my_link = $my_link || DownloadF($file,'l');
}
So if $my_link
evaluates to some true value then $my_link
will be assigned to itself (a no-op essentially), otherwise the result of DownloadF
is assigned.
Other assignment operators supported by perl:
**= += *= &= <<= &&=
-= /= |= >>= ||=
.= %= ^= //=
x=