my %List; $List{"a"}{"1"} = "yes"; $List{"a"}{"2"} = "no"; $List{"b"}{"1"} = "possibly"; $List{"b"}{"2"} = "never"; #### print "Before:\n"; foreach my $priKey (sort keys %List) { print "$priKey\n"; } if (exists $List{"c"}{"1"} ) { print "found a bad one\n"; } print "After:\n"; foreach my $priKey (sort keys %List) { print "$priKey\n"; } #### Before: a b After: a b c