Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^6: Rename unreliable on Windows

by elef (Friar)
on Apr 04, 2012 at 16:22 UTC ( #963474=note: print w/replies, xml ) Need Help??


in reply to Re^5: Rename unreliable on Windows
in thread Rename unreliable on Windows

Thanks. Hoping that copying is more robust than renaming, I tried this:
unlink "rename2.txt" or die "Can't delete file: $!"; copy ("rename1.txt", "rename2.txt") or die "Can't copy file: $!"; unlink "rename1.txt" or die "Can't delete file: $!";

Errors became less frequent, but they're still there. I'll try your suggestion. I really like the idea of sleeping increasing intervals between attempts, too.

-------------------
Edit: did the test, and the solution works. I also added some reporting to see how many extra attempts are needed for the renamings to succeed. The second attempt was sufficient every time, and it was needed ~50 times before the script got to 10000 loops. I'll implement this with 5 attempts max (just in case the backup sw spends more time on larger files) and forget about the issue. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://963474]
help
Chatterbox?
Discipulus shall be damned all progs that do not provide different font size!
[Corion]: Yeah - that's one important thing why I like to run my presentations from my browser. Ctrl+ and Ctrl- are incredibly helpful there to make sure everybody can read stuff
[Discipulus]: I 'm always at 125%, and fontsize 12

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-09-26 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?