Paul Makepeace wrote:
On Wed, May 28, 2003 at 10:42:55AM +0100, Dominic Mitchell wrote:

sub doit {


I like this method too, esp if combined with ?:


   local $_ = $_;
   return if $something;
   return if $other_thing;
   return 1;
}


Just for clarify, return requires a EXPR, it doesn't return $_ by
default.

return EXPR
return Returns from a subroutine, "eval", or "do FILE" with the value
given in EXPR. Evaluation of EXPR may be in list, scalar, or
void context, depending on how the return value will be used,
and the context may vary from one execution to the next (see
"wantarray"). If no EXPR is given, returns an empty list in
list context, the undefined value in scalar context, and (of
course) nothing at all in a void context.

Yup. I tend to abuse the "return alone means undef" quite a lot though, as you can see.


-Dom



Reply via email to