Over the course of this tutorial, I'll be examining Perl's arrays in detail, explaining what they are, how they work, and how you can use them to get things done faster, better and cheaper. In addition to providing a gentle introduction to Perl arrays and hashes in general, this article will also offer you a broad overview of Perl's array manipulation functions, providing you with a handy reference that should help you write more efficient code.
# returns an array of values @values = values(%matrix);
Most of the time, size and key information is used in the context of a loop that iterates over the array. Here's an example of how this might work in a numerically-indexed array,
print "Say hello to the characters in The Matrix: n";
# get the keys of the array with keys() # then use the keys to get the corresponding value # in a loop foreach $k (keys(%matrix)) { print $k, ": ", $matrix{$k}, "n"; }