Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^4: A DWIM too far?

by ihb (Deacon)
on Jun 18, 2004 at 02:22 UTC ( #367839=note: print w/replies, xml ) Need Help??

in reply to Re^3: A DWIM too far?
in thread A DWIM too far?

It seems you answered the wrong question. The problem is that you can't be sure to not overwrite a file by renaming it. Your rename subroutine does quite the opposite. Or have I completely misunderstood your reply?

Replies are listed 'Best First'.
Re^5: A DWIM too far?
by QM (Parson) on Jun 18, 2004 at 15:52 UTC
    I think you misunderstood (at least, I hope I've understood :)

    Rewriting rename to include the -i option (or -y option for Windoze) will not clobber an existing file (unless the underlying OS function has the same problem with the -i option, in which case we're all screwed.)

    I tried my example out, and it seemed to work as I intended. I'm sure someone has come up with a more robust and useful version. I was just trying to show that it was possible.

    Quantum Mechanics: The dreams stuff is made of

      The /Y operator on windows forces it to overwrite without confirmation /-Y forces confirmation and there is no documented way to force failure when a file exists already.

      Eric Hodges
        I thought I got it to work under XP. Here on Win2K, I agree with you.

        Ah well, I think it's just broken across the board.

        Quantum Mechanics: The dreams stuff is made of

        Don't use either?

        P:\test\data>type hello.dat Hello world P:\test\data>type goodbye.dat Goodbye cruel world P:\test\data>rename hello.dat goodbye.dat A duplicate file name exists, or the file cannot be found. P:\test\data>type hello.dat Hello world

        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-01-22 19:01 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (63 votes). Check out past polls.