I am trying to figure out how to delete a hash entry that returns a value of {}
.
I was working with something like this;
if (ref($snapshots{"ID\:$id"}) eq "{}") {
print "ID $id hash no snapshots\n";
}
It does not appear to work. Any ideas?
Given {}
, ref
will be "HASH"
not "{}"
if (ref $snapshots{"ID\:$id"} eq 'HASH' && !scalar keys %{$snapshots{"ID\:$id"}}) {
delete $snapshots{"ID\:$id"};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With