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

You might want to try {code with each} But I am not sure if you'll get all your new keys.

Actually, the docs for each specifically say that you should not do this - as each returns hash elements in an essentially random order (or at least in an unpredictable order), so doing something like this is playing with fire :).

CU
Robartes-

Replies are listed 'Best First'.
Re: Re: foreach loop question
by dmitri (Priest) on Apr 16, 2003 at 18:52 UTC
    That's what I meant by "I am not sure if you'll get all your new keys." I guess it did not come across that way.
Re: Re: foreach loop question
by djantzen (Priest) on Apr 16, 2003 at 19:14 UTC

    I always figured that each and related functions keys and values iterated over the hash from start to finish with the order being determined by the hashing algorithm. Can an internals person shed some light on what determines this "essentially random order"?


    "The dead do not recognize context" -- Kai, Lexx

      Unless you run the hashing algorithm in your head (I believe it's in hv.h), it'll look sufficiently random. :)