what does perl operator “||=” do?

后端 未结 4 1323
逝去的感伤
逝去的感伤 2021-01-29 12:32

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          


        
4条回答
  •  失恋的感觉
    2021-01-29 13:16

    If $my_link is false (empty string, 0 or undef) store DownloadF($file,'l') into $my_link

    This construct has always had problems when used to assign a default value (what if you want $my_link to be zero)

提交回复
热议问题