Perl Programming/Keywords/return

Previous: reset Keywords Next: reverse

The return keyword edit

The return operator returns from an do FILE, eval, or subroutine with the value in EXPRESSION. EXPRESSION can be evaluated in list, scalar, or void context, depending on the use of the return values. The context may vary from one execution to the other. Without an EXPRESSION, it returns an empty list in list context, undef in scalar context, and nothing at all in void context.

If return is omitted altogether, the value of the last evaluated expression is returned.

Unlike most named operators, return is also exempt from the looks-like-a-function rule. So, return ("foo")."bar" will cause "bar" to be part of the argument to return.

Syntax edit

 return EXPRESSION
 return
Previous: reset Keywords Next: reverse