in reply to Why is AofH the way it is?

For the same reason that this doesn't work:
my @x = qw(1 2 4 8 16); foreach (@x) { print $x[$_], "\n"; }
The value in $_ is not the index of the item being scanned. It is the item itself. So on the third iteration of the loop, you're trying to look at $x[4], and on the fourth iteration, $x[8]!

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.