Siddharth has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone, I am new to perl and have been going through some programs. The following code dealing with hash and array is has really confused me.
I can't understand what determines the relative ordering of elements.
In the output, why 'joe' comes between 'giggle' and 'dingbat'.
D: giggles 870 joe 2983 dingbat 33 mike -94 fred 44
@alex = ( fred => 44, 'joe' => 2983, mike => -94 ); %heather = ('This', 'will', 'actually', 'work'); %heather = @alex; print "C: [$heather{'fred'}] [$heather{'mike'}] [$heather('joe')] ", "[$heather{'This'}]\n"; $heather{'dingbat'} = 33; $heather{'giggles'} = 870; @alex = %heather; print "D: @alex\n";
C: [44] [-94] [('joe')] [] D: giggles 870 joe 2983 dingbat 33 mike -94 fred 44
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't figure out the realtive ordering.
by MidLifeXis (Monsignor) on Sep 26, 2011 at 03:01 UTC | |
|
Re: Can't figure out the realtive ordering.
by duyet (Friar) on Sep 26, 2011 at 06:26 UTC | |
|
Re: Can't figure out the realtive ordering.
by onelesd (Pilgrim) on Sep 26, 2011 at 04:20 UTC | |
|
Re: Can't figure out the realtive ordering.
by locked_user sundialsvc4 (Abbot) on Sep 26, 2011 at 13:01 UTC | |
|
Re: Can't figure out the realtive ordering.
by Siddharth (Initiate) on Sep 27, 2011 at 08:47 UTC |