To access array elements in Perl using index, you can use square brackets notation.
In this example,
@numbers
with integer values.2
using indexing $numbers[1]
.@numbers = (1, 2, 3, 4, 5);
print $numbers[1];
2
In this example,
@chars
with character values.3
using indexing $chars[2]
.@chars = ('a', 'b', 'c', 'd', 'e');
print $chars[2];
c
In this tutorial, we learned How to Access Array Elements using Index in Perl language with well detailed examples.