in reply to Re^3: Printing only the "keys that have a value" in hash
in thread Printing only the "keys that have a value" in hash

Unless I'm mistaken, this code won't do anything at all. You're getting each $key directly from the hash, so it's always going to exist. Perhaps you meant if (!defined $my_hash{$key})?

Anyway, checking for defined-ness won't matter either since the "undefined" values are actually empty array refs, which are defined.