In Perl, array is a special type of variable. The array is used to store the list of values and each object of the list is termed as an element. Elements can either be a number, string, or any type of scalar data including another variable.
How do I create an array in Perl?
- # original string.
- $string = “Where-There-Is-A-Will-There-Is-A-Way”;
- # transforming strings into arrays.
- @string = split(‘-‘, $string);
- print “$string[4]\n”;
How do you access an array in Perl?
To get a single scalar out of an array, access it with the [] and a $ sigil. All arrays in Perl start at 0. Arrays can also be accessed from the end by using negative offsets from the end.