Skip to content

Instantly share code, notes, and snippets.

@cou929
Created December 10, 2012 07:31
Show Gist options
  • Save cou929/4249052 to your computer and use it in GitHub Desktop.
Save cou929/4249052 to your computer and use it in GitHub Desktop.
perl ハッシュのデフォルト値. 存在しない key にアクセスすると作ってくれる
$ perl -MData::Dumper -le 'my $a = +{}; $a->{foo}->{bar}++; $a->{foo}->{bar}++; $a->{foo}->{baz}++; $a->{blah}->{blah}++; print Dumper $a;'
$VAR1 = {
'blah' => {
'blah' => 1
},
'foo' => {
'bar' => 2,
'baz' => 1
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment