What kind of syntactic sugar is available in Perl to reduce code for l/rvalue operators vs. if statements?

后端 未结 5 1577
时光说笑
时光说笑 2021-02-13 04:26

There\'s a bunch out there, as Perl is a pretty sugary language, but the most used statements in any language is the combination of if statements and setting values. I think I\

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 04:36

    There's also:

    $hash{$key||'foo'} = 1;  # if($key) { $hash{$key} = 1 } else { $hash{'foo'} = 1 }
    

提交回复
热议问题