Perl hash 進階使用

1. 巢狀hash

  • 可以直接指定深層次的值而不需先初始化淺層次
    $hash{"key_level_1"}{"key_level2"}...=value;
  • 當Value也是hash時,指定取出值為hash
    • %{$hash{"key_level"}}
  • 計算hash內element數量
    • my $count=keys %hash
    • my $deep_count=keys %{$hash{"key"}}

2.hash迴圈

  • for my $loopKey ( keys %hash) {...}
  • foreach my $loopKey (keys %hash) {...}
  • 多層hash迴圈
124213
  sfsfsdaf
   fsfsadfa
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: