Firstly, the first level of that hash assignment should be using parens and not curly braces. Now in answer to your first question, you will
delete the
def key in the hash pointed to by
$hash{abc}. As for the second question, just test that the hash is empty with the use of
keys in a scalar context e.g
use Data::Dumper;
my %hash = ( abc => {}, ghi =>{ qw/ two key value pairs / } );
print "before: ", Dumper \%hash;
delete $hash{abc} unless keys %{ $hash{abc} };
print "after: ", Dumper \%hash;
__output__
before: $VAR1 = {
'abc' => {},
'ghi' => {
'two' => 'key',
'value' => 'pairs'
}
};
after: $VAR1 = {
'ghi' => {
'two' => 'key',
'value' => 'pairs'
}
};