DO $$
  my $directory = "my_directory";
  mkdir $directory
    or elog(ERROR, qq{could not create the directory "$directory": $!});
  select(undef, undef, undef, 0.00000000001);
  rmdir $directory or elog(ERROR, qq{could not delete the directory "$directory": $!});
$$ LANGUAGE plperlu;
