Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Not in order in Hash output

by ikegami (Pope)
on Oct 10, 2012 at 22:30 UTC ( #998334=note: print w/replies, xml ) Need Help??


in reply to Not in order in Hash output

Just like arrays, hash return their elements in the order they are physically arranged in the hash. Hashes differ from arrays in that one cannot control the order in which elements are arranged, and the order can change whenever the number of hash element changes.

Replies are listed 'Best First'.
Re^2: Not in order in Hash output
by perl_walker (Novice) on Oct 11, 2012 at 12:34 UTC

    Try this,

    use strict; use warnings; use Tie::IxHash; my %hash1 = (); tie %hash1, "Tie::IxHash"; %hash1 = ("a",1,"b",2,"c",3,"d",4); while (my@values = each(%hash1)){ print "The key/value pair is @values \n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998334]
help
Chatterbox?
[marto]: good morning all

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2018-02-20 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (268 votes). Check out past polls.

    Notices?