What Is a Reference?

A reference is a form of data in Perl that indirectly points to some other bit of data. The reference itself is a scalar, like a number or string—it can be assigned to a scalar variable, printed, added to, tested to see if it's true or false, stored in a list, or passed to a subroutine, just as numbers and strings can. In addition to its scalar-like behavior, however, the reference also refers, or points to, the location of some other bit of data. To find out what the reference points to, you dereference the reference—fancy terminology for essentially following the pointer to the thing it points to.

Note

If you actually want more fancy terminology in your life, the thing the reference points to is called the referent. You ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.