K
kenneth
hi
i'd like to access to hash which contains hash and sclar var,and failed.
access to hash of hash is ok, i find that in <<Programming Perl>>.
use the code below:
for my $family ( keys %test ) {
print "$family: \n";
for my $role ( keys %{ $test{$family} } ) {
print "$role=$test{$family}{$role} ";
}
print "\n";
}
but now i construct a structure use below codes:
my %test=(
number => "20",
);
$test{"homepage"}{"index.html"}=21;
$test{"homepage"}{"index.php"}=2;
and the above code failed to access to the element of the structure with
error of "Can't use string ("20") as a HASH ref while "strict refs" in
use at hash_of_hash.pl line 26.
shell returned 255"
any advises? thank you!
i'd like to access to hash which contains hash and sclar var,and failed.
access to hash of hash is ok, i find that in <<Programming Perl>>.
use the code below:
for my $family ( keys %test ) {
print "$family: \n";
for my $role ( keys %{ $test{$family} } ) {
print "$role=$test{$family}{$role} ";
}
print "\n";
}
but now i construct a structure use below codes:
my %test=(
number => "20",
);
$test{"homepage"}{"index.html"}=21;
$test{"homepage"}{"index.php"}=2;
and the above code failed to access to the element of the structure with
error of "Can't use string ("20") as a HASH ref while "strict refs" in
use at hash_of_hash.pl line 26.
shell returned 255"
any advises? thank you!