M
Markus Dehmann
I am using a two-dim hash with a string as first key, and an array as 2nd
key. But it doesn't work! Can anyone tell me what's wrong?
#!/usr/bin/perl -w
$hash{"test"}{["one", "two"]} = 42;
$hash{"test"}{["three", "four"]} = 23;
my $key = "test";
foreach(keys %{$hash{$key}}){
print "Value for $_ is $hash{$key}{$_}\n"; # ARRAY(0x804c958)
# print "@$_\n"; # Can't use string ("ARRAY(0x804c958)") as an ARRAY ref
}
The output is:
Value for ARRAY(0x804c958) is 23
Why does it print only *one* value? Why can't I dereference
the array ref $_?
Thanks!
key. But it doesn't work! Can anyone tell me what's wrong?
#!/usr/bin/perl -w
$hash{"test"}{["one", "two"]} = 42;
$hash{"test"}{["three", "four"]} = 23;
my $key = "test";
foreach(keys %{$hash{$key}}){
print "Value for $_ is $hash{$key}{$_}\n"; # ARRAY(0x804c958)
# print "@$_\n"; # Can't use string ("ARRAY(0x804c958)") as an ARRAY ref
}
The output is:
Value for ARRAY(0x804c958) is 23
Why does it print only *one* value? Why can't I dereference
the array ref $_?
Thanks!