Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: A DWIM too far?

by ihb (Deacon)
on Jun 18, 2004 at 02:22 UTC ( [id://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.

    -QM
    --
    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.

        -QM
        --
        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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-19 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found