%hashA=( 'a'=>1, 'b' => 2 );
%hashB=( 'AA' => 22 );
$hashA{c}=\%hashB;
print exists $hashA{c}->{'AA'};---- 为什么*觉得*不行?楼主可能把其他语言的开发经验牵到 perl 上来了。 建议读读 perlreftut 和 perldsc http://perldoc.perl.org/perlreftut.html http://perldoc.perl.org/perldsc.html 先把 perl 的引用搞清楚,就明白了。 2009/7/14 yi wang <[email protected]> > 不行吧,这样怎么体现出二级结构呢?当你要用exists 的时候,应该怎么写呢? > > 2009/7/14 cnhack TNT <[email protected]> > > 要使用这样的结构,无须去刻意初始化 >> >> >> >> >> 2009/7/14 Young vincent <[email protected]> >> >>> 不是跟第一个一样,直接置空即可麽?%hash=();或是undef %hash; >>> >>> >>> 2009/7/14 yi wang <[email protected]> >>> >>>> 请明示,看不懂你的意思。 >>>> >>>> 2009/7/14 Young vincent <[email protected]> >>>> >>>>> 不一样麽,后面的该赋引用值,是一个地址来的~ 不信可以打印出来cc~ >>>>> >>>>> 2009/7/14 yi wang <[email protected]> >>>>> >>>>> 如题。 >>>>>> 比如%hash=();初始化一个一般的hash表为空,以后可以有类似 $hash{'key1'} = value1; 的赋值 >>>>>> 但是如果hash{'key1'}值又是一个hash表,即意为 %hash{'key1'} = %anotherhash, >>>>>> 应该如何初始化这样的hash的hash表为空? >>>>>> 谢谢! >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> 和你在一起 >>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> > > > -- > 和你在一起 > > > > --~--~---------~--~----~------------~-------~--~----~ 您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。 要在此论坛发帖,请发电子邮件到 [email protected] 要退订此论坛,请发邮件至 [email protected] 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛 -~----------~----~----~----~------~----~------~--~---
