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

后端 未结 6 1762
悲&欢浪女
悲&欢浪女 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条回答
  •  情歌与酒
    2020-12-21 05:11

    Short answer: it stops ("short circuits" as AJ points out). You can get a ton more detail here.

提交回复
热议问题