Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^5: non-scalar hash key

by citromatik (Curate)
on Jun 17, 2009 at 10:33 UTC ( #772327=note: print w/replies, xml ) Need Help??

in reply to Re^4: non-scalar hash key
in thread non-scalar hash key

The problem with your suggestion is that two arrays with the same elements will give two entries in the hash (because they will have different references). Consider:

use strict; use warnings; use Data::Dumper; my @foo = qw/1 2 3 4 5 6/; my @fu = qw/1 2 3 4 5 6/; my %bar = ( \@foo => 'elephants', \@fu => 'zebras' ); print Dumper \%bar;

Outputs something like:

$VAR1 = { 'ARRAY(0x18ae770)' => 'zebras', 'ARRAY(0x17f0ec8)' => 'elephants' };


my @foo = qw/1 2 3 4 5 6/; my @fu = qw/1 2 3 4 5 6/; my %bar = ( join ('',@foo) => 'elephants', join ('',@fu) => 'zebras' ); print Dumper \%bar;


$VAR1 = { '123456' => 'zebras' };


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://772327]
Discipulus spent ~3 hours on the roof.. with mediocre results..
[Eily]: what were you trying to do on the roof Discipulus?
[Eily]: if I had done the same here, I'd contain a swimming-pool worth of water by now...
[Discipulus]: i put some shodowing cloth against the killer sun. but i'm still not happy with this
Discipulus roof? or terrace? well is flat anyway, parallel to the ground
[Eily]: upper ground :P
[marto]: erix [id://1193617| pretty much
[marto]: err pretty much

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-06-29 12:58 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (665 votes). Check out past polls.