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

Re: Can't figure out the realtive ordering.

by duyet (Friar)
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2018-01-21 19:24 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (230 votes). Check out past polls.