如何在perl中嵌套哈希中获取内部哈希的大小?

Dco*_*der 0 perl hash

我有以下散列哈希:

%tgs = (
'articles' =>  {
                   'vim' => '20 awesome articles posted',
                   'awk' => '9 awesome articles posted',
                   'sed' => '10 awesome articles posted'
               },
'ebooks'   =>  {
                   'linux 101'    => 'Practical',
                   'nagios core'  => 'Monitor'
               }
);
Run Code Online (Sandbox Code Playgroud)

我使用以下:

$size = scalar keys (%{tgs{'articles'}});
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

gen*_*sym 5

$size = scalar keys (%{$tgs{'articles'}});应该成功 - 你忘了$ s​​igil.

哪个my $size = keys %{ $tgs{articles} };是更惯用的perl.