Skip to Main Content
Perl Pocket Reference, 5th Edition
book

Perl Pocket Reference, 5th Edition

by Johan Vromans
July 2011
Intermediate to advanced content levelIntermediate to advanced
104 pages
2h 14m
English
O'Reilly Media, Inc.
Content preview from Perl Pocket Reference, 5th Edition

Context

Perl expressions are always evaluated in a context that determines the outcome of the evaluation.

Boolean

A special form of scalar context in which it only matters if the result is true or false. Anything that is undefined or evaluates to an empty string, the number zero, or the string "0" is considered false; everything else is true (including strings like "00").

List

A list value is expected. Acceptable values are literal lists, arrays, and hashes. Slices of arrays, hashes, and lists are also acceptable. A scalar value will be interpreted as a one-argument list.

Scalar

A single scalar value is expected.

Void

No value is expected. If a value is provided, it is discarded.

The following functions relate to context:

scalar expr

Forces scalar context for the expression.

wantarray

Returns true in list context, false in scalar context, and undef in void context.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Testing: A Developer's Notebook

Perl Testing: A Developer's Notebook

Ian Langworth, Chromatic
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe

Publisher Resources

ISBN: 9781449311186Errata Page