37,719
社区成员
发帖
与我相关
我的任务
分享
my %hello = {
config => {
config1 => "went" ,
config2 => "love"
},
label => \{
label1 => "1234",
label2 => "2345"
},
cont => "zhangwetnao"
};
foreach my $k (keys(%{$hello{config}}))
{
print("$k => $hello{config}{$k}\n");
}
my %hello = {#错误,给哈希变量赋值要使用括号“()”
config => {#正确,对key config对应的value赋予哈希引用
config1 => "went" ,
config2 => "love"
},
label => \{#此处成了哈希引用的引用
label1 => "1234",
label2 => "2345"
},
cont => "zhangwetnao"
};
my %hello = (
config => {
config1 => "went" ,
config2 => "love"
},
label => {
label1 => "1234",
label2 => "2345"
},
cont => "zhangwetnao"
);
use strict;
my %hello = (
config => {
config1 => "went" ,
config2 => "love"
},
label => {
label1 => "1234",
label2 => "2345"
},
cont => "zhangwetnao"
);
while (my ($key, $value) = each %{$hello{config}}) {
print "$key = $value\n";
}
my $sref = \%hello;
while ( ( $key , $value ) = each %{$sref->{'config'}} ) {
printf "[asdfsf $key=$value]\n";
}