my @must_haves = qw( apple orange pear ); foreach my $collection (@collections) { foreach my $must_have (@must_haves) { $collection->{$must_have} = ... if not exists $collection->{$must_have}; } }