perl 结构$farther ={name,shiduan,age,55};$son ={name,xiaohui,a

问题描述:

perl 结构
$farther ={name,shiduan,age,55};
$son ={name,xiaohui,age,25};
$farther->{'children'}=[$son];
$daughter ={name,xiaoli,age,27};
push (@{$farther->{'children'}},$daugther);
print $farther->{children}->[1]->{name};
怎么显示不出来想要的值啊.指点下, push那里好像有点问题,又不知怎么解决;
1个回答 分类:综合 2014-11-22

问题解答:

我来补答
更好的写法是:
$farther ={"name","shiduan","age",55};
$son ={"name","xiaohui","age",25};
$farther->{children}=[$son];
$daughter ={"name","xiaoli","age",27};
push (@{$farther->{children}},$daughter);
print $farther->{children}->[1]->{name};

查看详情具体的说明
perl -w file.pl
显示问题!
Unquoted string "name" may clash with future reserved word at d line 1.
Unquoted string "shiduan" may clash with future reserved word at d line 1.
Unquoted string "age" may clash with future reserved word at d line 1.
Unquoted string "name" may clash with future reserved word at d line 2.
Unquoted string "xiaohui" may clash with future reserved word at d line 2.
Unquoted string "age" may clash with future reserved word at d line 2.
Unquoted string "name" may clash with future reserved word at d line 4.
Unquoted string "xiaoli" may clash with future reserved word at d line 4.
Unquoted string "age" may clash with future reserved word at d line 4.
显示有点问题,应该注意的!
Name "main::daugther" used only once: possible typo at d line 5.
Name "main::daughter" used only once: possible typo at d line 4.
Use of uninitialized value in print at d line 6.
暗示你的问题,错误的地方
===>
push (@{$farther->{'children'}},$daugther);
您可以重新写
push (@{$farther->{'children'}},$daughter);
 
 
展开全文阅读
剩余:2000
上一页:椭圆简单性质
下一页:求解这个表格