return - perldoc.perl.org

Perl Programming Documentation
Download Perl
Explore

Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

Tools

- Preferences

# return

Perl 5 version 18.2 documentation
Go to top
Show recent pages
Recently read

# return

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- 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 void context.

  (In the absence of an explicit `return`, a subroutine, eval, or do FILE automatically returns the value of the last expression evaluated.)

  Unlike most named operators, this 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`.