in reply to Fun with arrays and hashes

1. I haven't meddled with dbmopen or tiehash, but you could always check out the Tie::Array module. Or go with Storable, which is included in the standard distribution and will store anything.

2 & 3. A hash is not ordered, so there is no way to access the 'first' element. However, the keys( %hash ) function returns an array of the keys of a hash. This array is not ordered and calling keys repeatedly may or may not yield the same results. A common construct is to sort the keys before looping over the array; this will step through the hash in the alpabetical order of the keys, which is nearly but not really the same thing you are asking for in 2)

for my $key ( sort keys %myhash ) { print "$key: $myhash($key)\n"; }

Cheers,
--Moodster