Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Rename unreliable on Windows

by tobyink (Abbot)
on Apr 04, 2012 at 10:19 UTC ( #963399=note: print w/ replies, xml ) Need Help??


in reply to Rename unreliable on Windows

Script runs fine for me; no crashes. Windows 2008 R2, Perl 5.12.4.

I suspect you're triggering some sort of race condition in Windows' file locking, but even if I removed the print to STDOUT to try to speed things up, I wasn't able to trigger it. Sleeping for a few microseconds before calling rename might help.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Rename unreliable on Windows
Download Code
Re^2: Rename unreliable on Windows
by elef (Friar) on Apr 04, 2012 at 11:46 UTC
    Thanks, I tested this with usleep 50000; but it didn't help. See resolution above (backup software was locking files).
      Good catch.   Points out that any operation that might possibly fail, especially when run on end-user machines (that are commonly less-privileged than the [foolishly, too privileged] developer machines), should trap for runtime errors with eval or otherwise, and be prepared to handle them plausibly.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-09-21 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls