[Israel.pm] order of keys() and values()

Gaal Yahas gaal at forum2.org
Thu Mar 4 02:21:47 PST 2004

On Thu, Mar 04, 2004 at 10:09:21AM +0200, Yossi.Itzkovich at ecitele.com wrote:
> Does the order of the return lists of keys() and values() match ?
> I mean is the first element of keys() match the first element of values() ?

Yes, *but only for the current run of perl*. That is, the one-liner

     perl -le '%h = (1 .. 10); print keys %h'

Is not guaranteed to return the same output every time you invoke it,
and specifically you can't rely on the order staying the same across
versions of perl.

(In fact, in versions of perl from 5.8.1 onwards it's supposed to give a
random order every time; my 5.8.3 doesn't now that I try it and it seems
like a bug. See perlsec for more info.)

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list