# set up the base hash my %hashes = (); # in the loop: my $date = $4.$3.$2; if (my $hashref = $hashes{$date}) { print "$date - Hash exists\n"; # play with hash } else { my $hashref = {}; # create a new empty hash $hashes{$date} = $hashref; store the hashref in the main hash print "$date - Hash doesn't exist\n"; # play with hash }