How do I create a hash of hashes in Perl?

后端 未结 5 869
轮回少年
轮回少年 2021-01-18 05:26

Based on my current understanding of hashes in Perl, I would expect this code to print \"hello world.\" It instead prints nothing.

%a=();

%b=();
$b{str} = \         


        
5条回答
  •  借酒劲吻你
    2021-01-18 06:28

    Short answer: hash keys can only be associated with a scalar, not a hash. To do what you want, you need to use references.

    Rather than re-hash (heh) how to create multi-level data structures, I suggest you read perlreftut. perlref is more complete, but it's a bit overwhelming at first.

提交回复
热议问题