hotshot has asked for the wisdom of the Perl Monks concerning the following question:
will always run on the hash in the same order (not necessarly from the begining as in array, but still in the same order). what I need is a way to run on the hash in the same order but backwards, for example:while (($key, $val) = each(%hash)) { } # or by: foreach (keys(%hash)) { }
Is there a short way of doing that without having to run on 'keys' from end (with indexes and stuff like that)? BR> Thanks# if I have my @arr = keys(%hash); # and @arr is for example: qw(4 7 2 1 9) # I would expect to get somehow @backwardsArr = qw(9 1 2 7 4);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: running backwards on a hash
by davorg (Chancellor) on Dec 11, 2001 at 14:21 UTC | |
by hotshot (Prior) on Dec 11, 2001 at 14:27 UTC | |
by pixel (Scribe) on Dec 11, 2001 at 14:34 UTC | |
by hotshot (Prior) on Dec 11, 2001 at 14:39 UTC | |
|
Re: running backwards on a hash
by rob_au (Abbot) on Dec 11, 2001 at 14:39 UTC | |
|
Re: running backwards on a hash
by jlongino (Parson) on Dec 11, 2001 at 23:12 UTC | |
|
Re: running backwards on a hash
by Maclir (Curate) on Dec 11, 2001 at 20:59 UTC |