What's the difference between return; and return undef; in Perl

后端 未结 4 833
天涯浪人
天涯浪人 2020-12-09 15:55

Is there a difference between a subroutine that does

return;

and one that does?

return undef;
4条回答
  •  無奈伤痛
    2020-12-09 16:24

    I think I still agree with PBP though.

    1) You should avoid nesting function calls:

    my $result = bar();
    foo(1, $result, 2);
    

    2) You should always be explicit (when doing "complicated" things):

    foo(1, scalar bar(), 2);
    

提交回复
热议问题