If you know that there are not going to be any extra keys,
i.e. there are only going to be a combination of A, B and/or
C but never D just count the nember of keys returned as
follows:
print "At least one undefined!\n" unless( scalar( keys %$hash ) == 3 )
+;
Barring that, you might be able to sort out undesirebles
from the list, or if you can sort such that you can
guarantee the desired hashes are first, then just look at
the element that would contain the last of the desirables:
print "At least one undefined!\n" unless( ( sort { ...some function...
+ } keys %$hash )[3] eq 'C' );