in reply to Re: Re: foreach loop question
in thread foreach loop question

Well, thanks. But without "sort" it works the same way.

I should have been more explicit. It's "keys" that creates the new array, not the sort.

If you want to process all of the keys and values in a hash without creating a new array to hold the hash keys, look into "each".

while ( ($key, $value) = each %h ) { ...
This doesn't create an additional array. Note, though, that it's unsafe to manipulate the hash while you're iterating over it. The proviso in the docs reads:
If you add or delete elements of a hash while you’re iterating over it, you may get entries skipped or duplicated, so don’t. Exception: It is always safe to delete the item most recently returned by "each()".