#!/usr/bin/perl use strict; use warnings; # An example of using an array of hashes my @MasterArray = (); my %SubHash1 = ( 'ABC' => 2, 'DEF' => 3, ); my %SubHash2 = ( 'GHI' => 5, 'JKL' => 6, ); my %SubHash3 = ( 'MNO' => 8, 'PQR' => 9, ); # Now use push to append a reference to the hash into the array: push @MasterArray, \%SubHash1; push @MasterArray, \%SubHash2; push @MasterArray, \%SubHash3; # Extract the reference and build a temporary hash to access its elements: foreach my $ArrayElement (@MasterArray) { print "-----[ New Hash from Array ]---------------\n"; my %CurrentHash = %$ArrayElement; foreach my $CurrentKey (sort keys %CurrentHash) { my $CurrentValue = $CurrentHash{$CurrentKey}; print "Key {$CurrentKey} contains '$CurrentValue'\n"; } } print "-------------------------------------------\n"; exit; __END__