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.

Array references

Array references - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Array references

- [Voiceover] Array references are a common technique in Perl. They are simple, convenient, and you'll probably use them often. Here's a working copy of arrayref.pl from chapter 11 of the exercise files. You'll notice down here on line seven, I have an array and that array is initialized using the quote word operator. And then I take the reference of the array using the reference backslash operator, and I assign it to the scalar, which now contains the reference to the array. And then I use that reference for the foreach loop. I'm dereferencing using the at operator to say that I'm getting the entire array from the reference. And the reference itself is inside of curly brackets. So when I save this and run it, you see it does exactly what we expect. It passes each individual element of the array to the console using say. It's worth noting here that in many cases, it's possible and allowable and legal to omit those curly brackets. And when I save this and run it, you'll notice it still…

Contents