@u36g2000prf.googlegroups.co
m:
When a file is open does unlink automatically deletes the file or
it generates an error. Because I wrote a program to delete a file
and regenerate the file. if the file is not deleted the data
simply gets appended to the existing file. which results in wrong
results
Hmmmm ... What is the question?
If you script opened the file, close it before calling unlink.
If the file is opened in exclusive mode by another process, I am not
sure deleting it is the correct action in the first place.
If you don't want your script to continue if unlink failed, you
should check the return value of unlink.
On the other hand, not that this will solve whatever problem you are
having, I would not have messed with unlink at all:
open my $out_h, '>', 'report.txt'
or die "Cannot open 'report.txt': $!";
That truncates the file if it can be opened and would die if it
cannot. Beats appending junk to a file.
There are just two many combinations of problems and solutions that
might apply to your post. Please elaborate after reading the posting
guidelines for this group and may be taking a look at the following
page:
http://blogs.msdn.com/oldnewthing/archive/2008/04/15/8397753.aspx
Sinan
--
A. Sinan Unur <
[email protected]>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/