for my $element (@$arrayref) { print $element, "\n"; } for my $i (0 .. $#$arrayref) { print "$i: $arrayref->[$i]\n"; }