what does the double forward slash mean here?

前端 未结 2 2017
有刺的猬
有刺的猬 2020-12-09 02:39

I\'m new to Perl and came across this piece of code at work, I search for a while but did not find the answer. Can anyone help to explain its function in plain english? than

2条回答
  •  忘掉有多难
    2020-12-09 03:27

    Check for Logical Defined-Or in perlop, it is similar to || but it checks for undef value (not false one).

    Although it has no direct equivalent in C, Perl's // operator is related to its C-style or. In fact, it's exactly the same as ||, except that it tests the left hand side's definedness instead of its truth.

    So in short,

    my $abc = delete $args{ 'abc' } // croak 'some information!';
    

    will croak when $args{ 'abc' } returns undef value.

提交回复
热议问题