in reply to Re^6: Read in hostfile, modify, output
in thread Read in hostfile, modify, output

"Atomic rename()" by POSIX specifies a single rename operation.

Show some working code that demo's replacing a file using Perl that uses a single rename.

Replies are listed 'Best First'.
Re^8: Read in hostfile, modify, output
by Anonymous Monk on Dec 21, 2016 at 01:53 UTC
    echo foo>foo; echo bar>bar; perl -e 'rename("foo","bar")' works perfectly fine on Linux. But I don't get why you wanted me to test it, when I know what I'm talking about and I knew it would work ahead of time (but I did test again anyway just to make sure I don't look like a fool), whereas if you had read up on the subject and tested before posting you might have learned something that it seems you didn't know before.
      ... just to make sure I don't look like a fool ...

      Don't worry about that. The Anonymous Monk already looks a fool as the result of many and many a post, and nothing you or anyone else can do can change that. Now, had you a handle... :)


      Give a man a fish:  <%-{-{-{-<

      I wanted to see what would happen under your Linux system (Request for testing). Right now, I don't have a Unix box to test with and so I couldn't test on Linux before posting. I did test under Windows which is what I have.

      The OP was asking about Windows. There appears to be a difference between Win and Linux. Fair enough. And a good point. The details of how these file system operators actually work between OS'es requires experimentation. I have no problem with that idea - I believe it.