How do I create a hash of hashes in Perl?

后端 未结 5 926
轮回少年
轮回少年 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:15

    Hashes of hashes are tricky to get right the first time. In this case

    $a{1} = { %b };
    ...
    $a{2} = { %b };
    

    will get you where you want to go.

    See perldoc perllol for the gory details about two-dimensional data structures in Perl.

提交回复
热议问题