in reply to Returned value from subroutine is 1 when returning ""
my $o = ( mysub() || print STDERR "didn't work\n" );
You can get your exected result either with explicit parentheses(my $o = mysub() ) || print STDERR "didn't work\n";
or by swapping to the lower precedence or
my $o = mysub() or print STDERR "didn't work\n";
See Logical or, Defined or, and Exclusive Or in perlop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Returned value from subroutine is 1 when returning ""
by fidesachates (Monk) on Jan 06, 2011 at 16:23 UTC |