What the others have said about arrays and hashes being apples and oranges
is true, but here's one way to think of it: A Perl array is like arrays in
most languages -- it's a collection of data indexed by a number. A Perl
hash can be thought of as an array, but it's not indexed by a number, but by
a string. So, to look up something in an array, you can say "$array[23]"
but you can't say "$array['abcd']. (Actually, you can but you'll get
$array[0].) You _can_ say "$hash{'abcd'}" or "$hash{'whatever I damn well
please'}" and actually, you don't need the quotes; "$hash{abcd}" works just
as well. You can even say "$hash{99}" but the 99 will be interpreted as a
string so it's the same as "$hash{'99'}.
So now you might ask, "Well, if I can index a hash like I can index an
array, why should I use an array?" There are two reasons: maintaining
element order, and performance. As some of the others said, a hash is
implemented using a hashing algorithm on the index (which in Perl, we call a
key), and this results in the elements being stored in a seemingly random
order. So if you create a hash with keys from 'A' to 'J' and the read the
hash back using something sequential like a foreach loop, you won't get them
back in 'A' to 'J' order. If you create an array with indexes from 1 to 10
and read it back sequentially, you get them back in 1 to 10 order. This
property of arrays is very useful when using the array as a stack or a
queue, where, if you add an element at the end, it has to stay at the end.
Perl's push, pop, shift and unshift functions manipulate arrays in just this
way.
The other reason is performance. Although it is somewhat variable, I've
seen estimates that it is about 20% faster to use an array instead of a
hash. But don't let that sway you too much. If you need data to be indexed
using a string, then a hash is just what you want. But if you can
conveniently use a number as the index, an array is a better choice. And if
you want a stack or a queue or a plain list, an array is really the only
choice.
Hope this helps. You might also look up 'hashing' or 'hash algorithm' in
Google to get a better understanding of how a hash works.