On Wed, Apr 6, 2011 at 8:22 AM, Balachandran Sivakumar <benignb...@gmail.com
> wrote:

>         I am trying to learn hashes in perl. I created an hash
> variable with 4 keys. I tried printing the keys in the hash by:(hash
> variable is %machines)
>
> foreach $key (keys %machines) {
>     print "$key\n";
> }
>

In the perlvar 
documentation<http://perldoc.perl.org/perldata.html#List-value-constructors>,
there's a little blurb that says *Note that just because a hash is
initialized in that order doesn't mean that it comes out in that order. See
sort <http://perldoc.perl.org/functions/sort.html> for examples of how to
arrange for an output ordering.* It's easy to miss if you didn't know to
look for it.

My limited understanding is that Perl handles the order internally. Code
should never rely on a specific order.

-- 
Robert Wohlfarth

Reply via email to