Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Can't figure out the realtive ordering.

by duyet (Pilgrim)
on Sep 26, 2011 at 06:26 UTC ( #927797=note: print w/replies, xml ) Need Help??

in reply to Can't figure out the realtive ordering.

The order of an array is fixed, eg. $alex[1] is always 44. The order of an hash is not fixed! See perlintro for more info about hash/array.

You should use strict and warning in your code. There is an error in the code: $heather('joe') should be $heather{'joe'}, since you defined an hash %heather but there is no array @heather

Use Dumper to look at the data.

use strict; use warnings; use Data::Dumper; my @alex = ( fred => 44, 'joe' => 2983, mike => -94 ); print Dumper( \@alex ); my %heather = ('This', 'will', 'actually', 'work'); print Dumper( \%heather ); %heather = @alex; print Dumper( \%heather ); print "C: [$heather{'fred'}] [$heather{'mike'}] [$heather{'joe'}] ", " +[$heather{'This'}]\n"; $heather{'dingbat'} = 33; $heather{'giggles'} = 870; print Dumper( \%heather ); @alex = %heather; print Dumper( \@alex ); print "D: @alex\n";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927797]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2016-10-26 01:55 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.