Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: "unique" filename?

by Fastolfe (Vicar)
on Dec 03, 2000 at 22:17 UTC ( [id://44687]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $num = 12345;
    $dir = "/some/dir/";
    ...
    $num++ while -e "$dir/$num";
    
    open(F, ">$dir/$num") or die ...
    
  2. or download this
    use Fcntl;
    use FileHandle;
    ...
    $num++ while !sysopen(F, "$dir/$num", O_EXCL|O_CREAT, 0777) && $! eq "
    +File exists";
    
    die "$dir/$num: $!" if $!;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://44687]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-26 05:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found