小编Xom*_*omo的帖子

为什么我的多层哈希打印方式与我期望的一样?

这是代码,它不起作用,我想要做的是将Hash of Hashes传递给子程序aka函数,但它给出了一些奇怪的输出.

my %file_attachments = (
         'test1.zip'  => { 'price' => '10.00', 'desc' => 'the 1st test'},
         'test2.zip'  => { 'price' => '12.00', 'desc' => 'the 2nd test'},
         'test3.zip'  => { 'price' => '13.00', 'desc' => 'the 3rd test'},
         'test4.zip'  => { 'price' => '14.00', 'desc' => 'the 4th test'}
                   );

                   my $a="test5.zip";
                   my $b="the 5th test";

         $file_attachments{$a}->{'price'} = '18.00';
         $file_attachments{$a}->{'desc'} =$b;


        print(%file_attachments);


sub print{

my %file =@_;

foreach my $line (keys %file) {
        print "$line: \n";
         foreach my …
Run Code Online (Sandbox Code Playgroud)

perl hash hash-of-hashes

2
推荐指数
1
解决办法
134
查看次数

标签 统计

hash ×1

hash-of-hashes ×1

perl ×1