in reply to return if defined
Hello uncoolbob, and welcome to the Monastery!
How about using the Conditional Operator?
sub my_find_or_create { ... return defined $existing_result ? $existing_result : $new_result; }
Update: Or, better, just use Logical Defined Or:
return $existing_result // $new_result;
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: return if defined
by Anonymous Monk on Dec 20, 2012 at 12:34 UTC | |
by uncoolbob (Novice) on Dec 20, 2012 at 12:43 UTC | |
by Anonymous Monk on Dec 20, 2012 at 13:00 UTC | |
by Anonymous Monk on Dec 20, 2012 at 13:39 UTC | |
by Anonymous Monk on Dec 20, 2012 at 13:55 UTC | |
by tobyink (Canon) on Dec 20, 2012 at 14:14 UTC | |
|
Re^2: return if defined
by uncoolbob (Novice) on Dec 20, 2012 at 12:13 UTC | |
by Athanasius (Archbishop) on Dec 20, 2012 at 12:48 UTC |