Reference Basics

You create and assign a normal scalar variable by using an assignment operator, as follows:

$a="Stones";   # A normal scalar

After this snippet, a scalar variable called $a is created, and it contains the string "Stones". Now, somewhere within the computer's memory, there is a place labeled $a that contains that string, as illustrated here:

If you were to assign the scalar $a to $b—like $b=$a;—you would wind up with two copies of the data, withtwo different names, as shown here:

Having two copies might be acceptable if you want ...

Get SAMS Teach Yourself Perl in 24 Hours THIRD 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.