Hashes with the same keys won't necessarily return the keys in the same order, as shown below. However, as
Juerd points out, the order shouldn't change for a given hash if the keys don't change, also shown below.
The only problem that I can see is that the order the keys are returned in might change in a future release. So, I wouldn't rely on that.
#!/usr/bin/perl -wl
use strict;
my %h1;
my %h2;
@h1{1..10} = undef;
print join " ", keys %h1;
@h1{5..10, 1..4} = undef;
print join " ", keys %h1;
@h2{5..10, 1..4} = undef;
print join " ", keys %h2;
__END__
Prints:
1 2 3 10 4 5 6 7 8 9
1 2 3 10 4 5 6 7 8 9
1 2 3 4 10 5 6 7 8 9
--
John.