O'Reilly logo

Sams Teach Yourself Perl in 21 Days, Second Edition by Rafe Colburn, Laura Lemay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Basics: A General Overview of How to Use References

Let's look at a few simple examples of creating and using references so you can get a feel for the technique. Perl actually has a number of ways of working with references, but here we'll focus on the easiest and most popular mechanisms, and explore the others in a later section (“Other Ways of Using References”).

Creating a Reference

Start with something you've seen a gazillion times before in this book: A plain old scalar variable that contains a string.

$str = "This is a string."

This is an ordinary scalar variable, holding ordinary scalar data. There's some location in memory that stores that string, which you can get to through the $str variable name. If you assigned something else ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required