What is the difference between Perl's ( or, and ) and ( ||, && ) short-circuit operators?

前端 未结 5 1391
暖寄归人
暖寄归人 2020-11-29 06:44

Which of these subroutines is not like the other?

sub or1 {
    my ($a,$b) = @_;
    return $a || $b;
}

sub or2 {
    my ($a,$b) = @_;
    $a || $b;
}

sub          


        
5条回答
  •  一生所求
    2020-11-29 07:12

    In Perl 5, "or" and "and" have lower precedence than "||" and "&&". Check out this PerlMonks thread for more info:

    http://www.perlmonks.org/?node_id=155804

提交回复
热议问题