http://www.perlmonks.org?node_id=662270


in reply to Re: Sequential defined-or operators
in thread Sequential defined-or operators

It's wonderful, ikegami! My worries disappear right away.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Replies are listed 'Best First'.
Re^3: Sequential defined-or operators
by ikegami (Patriarch) on Jan 14, 2008 at 12:18 UTC

    Just be careful with precedence. Absent prototypes overriding the default,

    my $value = $hash{$arg} // func $arg // 'default';
    means
    my $value = $hash{$arg} // func($arg // 'default');

    Putting parens around the low precedence bit solves the problem.

    my $value = $hash{$arg} // (func $arg) // 'default';

    Of course, with functions, you can also do

    my $value = $hash{$arg} // func($arg) // 'default';
      Yes, I'm aware about this issue. I wrote related matter sometime ago. So I believe it will be perfectly fine to write:
      my $value = $hash{$key} // func $arg // 'default';
      knowing that func is a unary operator.

      Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!