Most people's replies seem to be focusing on the details of the implementation, but this isn't the greatest idea. One can, however, make certain conclusions based only on guarantees in the documentation:
(perldoc -f keys)
The keys are returned in an appar-
ently random order. The actual random order is
subject to change in future versions of perl, but
it is guaranteed to be the same order as either
the `values' or `each' function produces (given
that the hash has not been modified).
That's exactly how much you can count on - the fact that it is "the same order as" values() and each() means that it also must be the same order as future calls to keys() (by the transitivity property of the word "same"). If you make *any* changes to the hash, this guarantee goes away.
Of course, this is *not* the same as the OP's original phrase "provided of course that the keys are the same" - you can insert & delete things in a hash and end up with the same eventual set of keys, but your modifications may still change the order of keys().
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|