Skip to content

Instantly share code, notes, and snippets.

@pwr22
Created January 18, 2015 22:19
Show Gist options
  • Save pwr22/c63c0e3f3309d0c95344 to your computer and use it in GitHub Desktop.
Save pwr22/c63c0e3f3309d0c95344 to your computer and use it in GitHub Desktop.
Hash of Arrays of Hashes in Perl
# This is a hash
my %hashOfArraysOfHashs = ( key1 => [ { innerKey1 => 'is me', innerKey2 => 'is me' },
{ innerKey1 => 'is me', innerKey2 => 'is me' }],
key2 => [ { innerKey1 => 'is me', innerKey2 => 'is me' },
{ innerKey1 => 'is me', innerKey2 => 'is me' },
{ innerKey1 => 'is me', innerKey2 => 'is me' }]);
# This is a hashref
my $hashOfArraysOfHashs = { key1 => [ { innerKey1 => 'is me', innerKey2 => 'is me' },
{ innerKey1 => 'is me', innerKey2 => 'is me' }],
key2 => [ { innerKey1 => 'is me', innerKey2 => 'is me' },
{ innerKey1 => 'is me', innerKey2 => 'is me' },
{ innerKey1 => 'is me', innerKey2 => 'is me' }]};
# These also a hashref
my $href = \%{$hashOfArraysOfHashs}
my $href2 = {%hashOfArrayOfHashs}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment