in reply to Re: hash unorderly output
in thread hash unorderly output

Not conceptually that much more difficult, you just have to maintain an array and push the key to it every time you add a key to your hash, then to get the output in the order it went in something like:

foreach my $key (@ordered) { ...

----------
My cow-orkers were talking in punctuation the other day. What disturbed me most was that I understood it.

Replies are listed 'Best First'.
Re^3: hash unorderly output
by jdporter (Paladin) on May 25, 2005 at 11:14 UTC
Re^3: hash unorderly output
by Limbic~Region (Chancellor) on May 25, 2005 at 13:03 UTC
    Nevtlathiel,
    you just have to maintain an array and push the key to it every time you add a key

    It is actually a bit more complicated than that though none of the problems can't be overcome. If you delete a key you either need to splice out the corresponding array element or do an exists test when looping over the array. If you change a key's value should it then go to the end or stay put? I am not saying that it is isn't that simple in specific cases, but in general it is usually better to just use an already made wheel:

    Cheers - L~R