in reply to Re^3: What's the opposite of // (err) operator?
in thread What's the opposite of // (err) operator?

Very interesting. So the precedence of // is low enough so it uses everything except the assignment as the left arg. It seems odd to me to return in the middle of a value-bearing expression, but I'm too used to C++. Thanks for pointing that out.
  • Comment on Re^4: What's the opposite of // (err) operator?

Replies are listed 'Best First'.
Re^5: What's the opposite of // (err) operator?
by Tux (Canon) on May 11, 2011 at 07:17 UTC

    What version of perl, and which part of the docs? I can "fix" it for the development branch.


    Enjoy, Have FUN! H.Merijn
      http://perldoc.perl.org/5.10.1/perlop.html#Logical-or,-Defined-or,-and-Exclusive-Or Perhaps add your comments above as to the brief availablity of err after the mention of xor. Ikigama's observation that you might not even need the lower-precedence version would be good to tell people, too.

        I've just browsed that page, and I don't see the word "err" being mentioned anywhere at all, so I have nothing to fix.

        The current docs only mention err in the delta files for 5.9.x:

        perl-git/pod > grep -w err * perl590delta.pod:It has a low-precedence counterpart, C<err>, which ha +s the same precedence perl593delta.pod:(adds a C<say> built-in function), and C<err> (adds a +n C<err> keyword). perl593delta.pod:Note that C<err> low-precedence defined-or operator u +sed to be enabled by perldebtut.pod: DM<3>X ~err perlhack.pod:documented. If you are going to err, it is better to err +on the side of perltodo.pod: errno_t err = fopen_s(&f, __FILE__, "r"); perl-git/pod >

        Enjoy, Have FUN! H.Merijn
Re^5: What's the opposite of // (err) operator?
by ikegami (Patriarch) on May 11, 2011 at 15:28 UTC
    Well, it depends on the expression. You can always use parens around the expressions. They should rarely be required, though, since the expression is probably an array or hash lookup, or a function call. (I use parens on around function call argument lists.)