From the course: Perl 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding values and references

Understanding values and references - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Understanding values and references

- [Voiceover] A reference is a scaler that refers to a value. The target value may be a scaler, an array, a hash, or a function. The reference itself is a scaler value. You create a reference with the backslash character. You may create a reference to a scaler, an array, a hash, or a function. You may then access the target value by dereferencing using the correct type symbol and enclosing the scaler reference in curly brackets. Or for convenience, you may use the arrow operator to dereference and access structure members at the same time. References allow the use of anonymous arrays, hashes, and functions. This can be extremely handy for creating complex data structures. If you need to know the type of reference, you may use the ref function. The ref function returns a string indicating the type of the referenced value. References are an important part of the Perl language. You'll use them to create rich, complex data structures, and you will see them often in existing code.

Contents