in reply to Re: Perl5 Language Extension: Definedness-Triggered Shortcut Operators
in thread RFC: Perl5 Language Extension: Definedness-Triggered Shortcut Operators

I doubt it:
perl -E 'my $x = 0 ; say $x // "true" ' 0
  • Comment on Re^2: Perl5 Language Extension: Definedness-Triggered Shortcut Operators
  • Download Code

Replies are listed 'Best First'.
Re^3: Perl5 Language Extension: Definedness-Triggered Shortcut Operators
by ww (Archbishop) on Mar 17, 2012 at 13:20 UTC
    And, explained by aaron_baugher, below:
    C:\>perl -E "my $x = 0 ; say $x // 'true'; my $y = 1; say $y // 'true' +;$x = undef; my $a=$x // warn 'RHS evaluated'; say $a;" 0 1 RHS evaluated at -e line 1. 1
    updated.

      Isn't this because the precedence makes it:

      $x = undef; my $a=($x // warn 'RHS evaluated'); say $a;

      Since $x is not defined, // returns the right hand side, and the call to warn returns 1 (true) to report success.

      Aaron B.
      My Woefully Neglected Blog, where I occasionally mention Perl.