in reply to tempdir with template fails

I find renaming the directory works best.
perl -MFile::Copy -MFile::Temp=tempdir -e 'move $_=tempdir( "asd-XXXX" + ), $_.".mbox";'



perl -e '$,=$",$_=(split/\W/,$^X)[y[eval]]]+--$_],print+just,another,split,hack'er

Replies are listed 'Best First'.
Re^2: tempdir with template fails
by Skeeve (Parson) on Dec 03, 2006 at 20:36 UTC

    No.... What if (by accident) a tempdir is created which already exists as .mbox?

    My solution now is - as I don't need the directory at a specific place:
    1. Create a standard tempdir
    2. Create a fixed "name.mbox" directory within that directory

    Nevertheless: Thanks to you and all the others who answered.


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
      Sure, it was just a one-liner to demonstrate my approach. If i were to be more pragmatic, i would code around the various exceptions.

      Maybe something like this could be of help in this instance??
      #!/usr/bin/perl -Wl use strict; use File::Spec qw| catdir tmpdir |; my $tmpdir; sub repl { my @CHARS = ("a".."z", "0".."9"); local $_ = pop; s/ X / $CHARS[int rand $#CHARS] /gex; $_; } do { $tmpdir = File::Spec->catdir( File::Spec->tmpdir , repl ("asd-XXXX +.mbox") ); } until (!-e $tmpdir); print $tmpdir;


      perl -e '$,=$",$_=(split/\W/,$^X)[y[eval]]]+--$_],print+just,another,split,hack'er