Chapter 13. Does This Job Require a Reference?

Does This Job Require a Reference?

What Is a Reference? What Is a Pointer?

You can use the terms “reference” and “pointer” interchangeably in Perl. A reference is a variable that refers to another one. In short, it contains the address of another variable. We have seen the usefulness of references when passing values to a subroutine (Chapter 11). We can also use references, or pointers, to create more complex data types, such as a hash that contains a key followed by a list of values, or an array of arrays, etc. and we will need references in the next chapter when creating Perl objects.

Symbolic versus Hard References

A hard reference

Get Perl by Example, Fourth 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.