#!/usr/bin/env perl use strict; use warnings; my @nodes = qw/foo quux baz/; my %HoH = ( foo => { day => 'Mon' }, bar => { day => 'Tue' }, baz => { day => 'Wed' } ); # Loop over nodes for my $node (@nodes) { if (exists $HoH{$node}) { print "Node $node found in HoH and deleted\n"; # Do more processing here delete $HoH{$node}; } else { print "Node $node not found in HoH\n"; } } # Loop over remaining unmatched keys for my $key (keys %HoH) { print "Key $key with payload $HoH{$key}->{day} not matched, so added\n"; }