9.1. Symbolic References

Now that you're putting use strict in all of your programs, let's look at the class of run-time exceptions it can generate. One instance is from the use of symbolic references.

What's a symbolic reference? It's when a scalar contains a string that names another variable, and you attempt to use that scalar as though it were a hard reference. This works, if you're not using strict or have selectively disabled the component of use strict that prevents it.[3]

[3] You do this with the statement no strict 'refs'.

Now, in Perl 4, storing the name of a variable inside another variable was the only way to carry out certain very common tasks (and required that you also use eval). But since the advent of hard references in Perl 5, ...

Get Perl Debugged now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.