declare array in perl code example
Example 1: perl print array
# Perl
# syntax
print "@<array-name>";
# example
my @AgesArray = (25, 30, 40);
print "@AgesArray"; # OUTPUT: 25 30 40
Example 2: perl array
#!/usr/bin/perl
@ages = (25, 30, 40);
@names = ("John Paul", "Lisa", "Kumar");
print "\$ages[0] = $ages[0]\n";
print "\$ages[1] = $ages[1]\n";
print "\$ages[2] = $ages[2]\n";
print "\$names[0] = $names[0]\n";
print "\$names[1] = $names[1]\n";
print "\$names[2] = $names[2]\n";