fidesachates has asked for the wisdom of the Perl Monks concerning the following question:
The first print will output a "1" while the second one will output the expect value of "". Can someone please explain why this occurs and any other symptoms like it? (E.g. If a different value gets returned depending on what the function after || is). Thanks.#!/usr/bin/perl -w use strict; my $o = mysub() || print STDERR "didn't work\n"; print $o; print "\n"; $o = mysub(); print $o; print "\n"; sub mysub { return ""; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Returned value from subroutine is 1 when returning ""
by chromatic (Archbishop) on Jan 06, 2011 at 16:13 UTC | |
by fidesachates (Monk) on Jan 06, 2011 at 16:21 UTC | |
by Fletch (Bishop) on Jan 06, 2011 at 19:51 UTC | |
|
Re: Returned value from subroutine is 1 when returning ""
by kennethk (Abbot) on Jan 06, 2011 at 16:18 UTC | |
by fidesachates (Monk) on Jan 06, 2011 at 16:23 UTC | |
|
Re: Returned value from subroutine is 1 when returning ""
by mjscott2702 (Pilgrim) on Jan 06, 2011 at 16:21 UTC | |
by DrHyde (Prior) on Jan 07, 2011 at 10:29 UTC | |
|
Re: Returned value from subroutine is 1 when returning ""
by locked_user sundialsvc4 (Abbot) on Jan 06, 2011 at 16:57 UTC |