From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Lists and arrays - Perl Tutorial
From the course: Perl 5 Essential Training
Lists and arrays
- [Voiceover] A list is a fixed series of scalar values. For example, here is a working copy of hello.pl from chapter four of the exercise files, and if I come down here and say in parentheses, 1, 2, 3, and build and run, you see I get a 1, a 2, and a 3, all right next to each other like that. That's because in parentheses those three values, separated by commas, are a list. A list is enclosed in parentheses and the elements in the list are separated with commas. You can easily iterate a list using foreach and we'll talk more about loops later in this course, but for now, foreach looks like this, or at least on kind of foreach looks like this. If I save and run, you see it says, 1, 2, 3 on separate lines so say is now being called foreach value in the list. List elements may be numbers, strings, or any scalar. So instead of these numbers, I can use strings, and save and run, and you see we have that result that we expect. You may use the quote word operator to easily create a list of…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.