# maybe you can directly iterate on the input, rather than iterate over %first_hash # Get the contained hashes (which are the values of the top hash), because the keys are not used for my $subhash (values %first_hash) { my $key = $subhash->{LABEL}; # You have the key above, and the associated value is actually $subhash ... }