Advanced Functions

Learn about advanced functions in Perl.

Functions are the foundation of many advanced Perl features.

Context awareness

Perl’s built-ins know whether we’ve invoked them in void, scalar, or list context. So too can our functions. The wantarray built-in returns undef to signify void context, a false value to signify scalar context, and a true value to signify list context. Yes, it’s misnamed; see perldoc -f wantarray for proof.

Get hands-on with 1200+ tech skills courses.