From: Yuval Kogman Date: Mon, 31 Aug 2009 19:25:58 +0000 (+0300) Subject: refactor the case of abortive when() X-Git-Tag: Try-Tiny-0.01~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4459911118ff6db821be5f15bd2fa48cc66f70ba;p=p5sagit%2FTry-Tiny.git refactor the case of abortive when() --- diff --git a/lib/Try/Tiny.pm b/lib/Try/Tiny.pm index 5932535..477ef64 100644 --- a/lib/Try/Tiny.pm +++ b/lib/Try/Tiny.pm @@ -65,9 +65,12 @@ sub try (&;$) { for ($error) { return $catch->($error); } - } else { - return; + + # in case when() was used without an explicit return, the C + # loop will be aborted and there's no useful return value } + + return; } else { # no failure, $@ is back to what it was, everything is fine return $wantarray ? @ret : $ret[0];