use strict;
use warnings;
use File::Temp 'tempdir';
$File::Temp::KEEP_ALL = 1;
my $x = tempdir(CLEANUP=>1);
print "tmp $x\n";
# exit(1); # this will retain it
# ...
# on successful end of test
done_testing;
$File::Temp::KEEP_ALL = 0;
File::Temp::cleanup();
if( -d $x ){ print "still there ($x) ...\n" }