Shishir K. Singh wrote:

>>Hi,
> 
>>I want to open a temporary file somwhere and I am facing the problem of
>>making sure I dont write to an already existing temporary file, thus
>>curropting some other process somewhere else. Is there a way of telling
>>perl to open a new file for writing but to throw an error if the file
>>already exists?
> 
>>Thanks,
>>James.
> 
> Why don't you use new_tmpfile class method of IO::File
> 
> use IO::File;
> $fh = IO::File->new_tmpfile or die "Error:Unable to open File $!\n";
> 
> This creates a temporary file...you won't have to bother
> 
> See Cookbook section 7.5 for more details!!

Hmmmm, Part 2 of this question:

Is it possible to do this with a file name that *I* specify? Call a open 
command with a specfied filename that will give an error if the file 
already exists but otherwise create it & open it for writing?

I'm afraid I'm being very fernickety here; the code I'm writing needs to 
run on a range of systems; debian, free bsd, mac os x, and preferaly 
windows to so I'm very fussily avoiding calling as little extra baggage as 
needed. I could use calls to RCS to achieve what I want but I want to avoid 
that ...

Thanks again; James.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to