my $lock_file; my $lock_file_destroyer = Object::Destroyer->new(sub{ unlink($lock_file) if defined($lock_file); }); ... #### my $lock_file; END { unlink($lock_file) if defined($lock_file); } ...