To access array elements in Perl, you can use indexing with square brackets.
In this example,
@numbers
with numeric values.1
using indexing $numbers[1]
.@numbers = (1, 2, 3, 4, 5);
print $numbers[1];
2
In this example,
@fruits
with string values.@fruits = ('Apple', 'Banana', 'Orange');
foreach $fruit (@fruits) {
print "$fruit\n";
}
Apple Banana Orange
In this tutorial, we learned How to Access Array Elements in Perl language with well detailed examples.