Hi,

         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";
}

I noticed that the order in which the keys are printed is different
from the order in which I stored them. Is that expected ? If so, what
determines the order.

Another question is that, when I tried something like:

my @my_machines = %machines;
print "@my_machines\n";

I noticed that the output is exactly the reverse of the order in which
I had stored them in the hash. Is this also the expected behaviour ?
If so what is the reason behind that ?

Can someone please help me with these 2 newbie questions ?


PS: I am used to program. So, if I am doing something that is not the
perl way of doing it, please do let me know. Thanks


-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.

Mail: benignb...@gmail.com
Blog: http://benignbala.wordpress.com/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to