Is Perl optimized to skip remaining logic operands if the answer is already decided?

后端 未结 6 1764
悲&欢浪女
悲&欢浪女 2020-12-21 04:22

For instance, I need to match some text if $do eq \'b\'. If I run this code:

if (($do eq \'b\') && (/text/))
{
do stuff
}
6条回答
  •  猫巷女王i
    2020-12-21 05:02

    No, right part of condition is not evaluated when left part is false,

    if ($do eq 'b' && /text/)
    {
    do stuff
    }
    

提交回复
热议问题