%hash{'key1'} = %anotherhash
^^^^
这样是无法实现你的意愿的,多重的 hash 或者数组结构,你得使用引用:

%hash{'key1'} = \%anotherhash

这样, $hash{'key1'} 便指向了 %anotherhash, 此时你要访问 %anotherhash 中的内容(比如其中一个 keyA
的值)可以这样:

$hash{'key1'}{'keyA'} 或者 $hash{'key1'}->{'keyA'}


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 访问该论坛
-~----------~----~----~----~------~----~------~--~---

回复