in reply to Re: Returned value from subroutine is 1 when returning ""
in thread Returned value from subroutine is 1 when returning ""

Oh I understand now. I seem to have misunderstood the ||.

I read the code as (my $o = mysub()) || print ...

I see now that the grouping is my $o = (mysub() || print ...

Thank you.

Replies are listed 'Best First'.
Re^3: Returned value from subroutine is 1 when returning ""
by Fletch (Bishop) on Jan 06, 2011 at 19:51 UTC

    When in doubt about what exactly the precedence will be, B::Deparse is your friend.

    $ perl -MO=Deparse,-b,-p -e 'my $o = mysub() || print STDERR "WHY U NO + WORK\n";' (my $o = (mysub() || print(STDERR "didnt work\n")));

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.