raybies has asked for the wisdom of the Perl Monks concerning the following question:
I've got a sub that returns two arguments if it succeeds, and a single 0 if it fails...
I wanna know a quick single line way I can state:
if (my ($x, $y) = mysub ($args)) { #returned defined pairs do stuff... } else { #returned single zero. do other stuff... }
Essentially I want to return multiple values--but if they're not all returned, then use that as a function failed condition. Of course this is probably breaking all the programming rules of the universe by wanting to do this... but then again... I'm okay with that.
Currently even when I return 0, if it's written above, it thinks it's passed.
Thanks! --Ray
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: if multiple arg return or single fail?
by ikegami (Patriarch) on Mar 07, 2011 at 16:39 UTC | |
by raybies (Chaplain) on Mar 07, 2011 at 16:52 UTC | |
|
Re: if multiple arg return or single fail?
by JavaFan (Canon) on Mar 07, 2011 at 17:08 UTC | |
by raybies (Chaplain) on Mar 07, 2011 at 17:49 UTC | |
|
Re: if multiple arg return or single fail?
by toolic (Bishop) on Mar 07, 2011 at 16:42 UTC | |
by raybies (Chaplain) on Mar 07, 2011 at 16:55 UTC | |
|
Re: if multiple arg return or single fail?
by jethro (Monsignor) on Mar 07, 2011 at 16:48 UTC | |
|
Re: if multiple arg return or single fail?
by anonymized user 468275 (Curate) on Mar 07, 2011 at 16:55 UTC | |
|
Re: if multiple arg return or single fail?
by mellon85 (Monk) on Mar 07, 2011 at 17:22 UTC |