in reply to can't use string as hash ref
It is sort of confusing to me as to why, but if you have a multi-level hash, the first key must be able to vary, it cannot be a scalar reference to some other data structure or object.
#!/usr/bin/perl use warnings; use strict; my %hash; my @array = (1..100); # this will be ok $hash{\@array} = 42; # but this will issue an error, because \@array # cannot be used as a key which varies $hash{\@array}{1} = 42; # this will be ok $hash{1}{\@array}{1} = 42; #this will be ok $hash{1}{\@array}{1}{1} = 42;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: can't use string as hash ref
by morgon (Priest) on Oct 26, 2010 at 02:56 UTC | |
by andal (Hermit) on Oct 26, 2010 at 09:54 UTC | |
|
Re^2: can't use string as hash ref
by Anonymous Monk on Oct 25, 2010 at 12:30 UTC | |
by spickles (Scribe) on Oct 25, 2010 at 15:46 UTC |