This seems to work to only delete the corpse if it is empty:
Code:
my $deadnpc = $entity_list->GetCorpseByName("Tiny_Albino_Rat's corpse423");
if ($deadnpc->IsEmpty()) {
my $delete_corpse = $deadnpc->CastToCorpse();
$delete_corpse->SetDecayTimer(1); }
The only thing left is to figure out how to select corpses without having to provide an exact name or entity ID number.