Perl Programming/Keywords/wantarray

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: waitpid Keywords Next: warn

The wantarray keyword[edit | edit source]

The function wantarray returns true, if eval or the context of the currently executing subroutine is looking for a list value, and returns false, if the context is looking for a scalar. wantarray returns the undef, if the context is looking for no value (void context).

The result of wantarray() is unspecified in the top level of a file, in a wantarray, BEGIN, CHECK, INIT, END, or UNITCHECK block. The same is the case for the DESTROY method.

Syntax[edit | edit source]

  wantarray PID, FLAGS
Previous: waitpid Keywords Next: warn