[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Puzzle - Temp file creation



This has the outward appearance of attempting to make a temporary file
      $TMPDIR/quickblastout${$}aaaa
and, if it can't, working successively through
      $TMPDIR/quickblastout${$}aaab
      $TMPDIR/quickblastout${$}aaac
      $TMPDIR/quickblastout${$}aaad

until a tmp file is made or $tries hits 0

What is wrong with this code?

   # find a suitable temporary name
   $target = "$TMPDIR/quickblast${$}aaaa";
   my $tries = 100;
   while (--$tries) {
     last if IO::File->new($target,O_WRONLY|O_EXCL|O_CREAT,0600);
     $target++;
   }


HINT below
















something very like this came across comp.lang.perl.moderated a week or so ago.
-- --
        |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
  ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
       |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
      '---''(_/--'  `-'\_) http://www.cfcl.com/~vlb  http://www.macperl.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe