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

There isn't one. But then again, you don't need one. A low-precedence variation would cause a needless assignment to be performed.

my $x = EXPR // return; ... continue using $x

Replies are listed 'Best First'.
Re^4: What's the opposite of // (err) operator?
by John M. Dlugosz (Monsignor) on May 11, 2011 at 07:14 UTC
    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.

      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.

      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.)