Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: A DWIM too far?

by hv (Parson)
on Jun 19, 2004 at 13:57 UTC ( #368173=note: print w/ replies, xml ) Need Help??


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

Note that if you want to do a "safe" rename, you can do so, although it involves a copy

I may have missed something, but I think it can be done much more easily like this:

sub rename_i { my($src, $dest) = @_; link($src, $dest) or die "Can't link $src to $dest: $!"; unlink($src) or die "Can't unlink $src: $!"; }

Hugo


Comment on Re^2: A DWIM too far?
Download Code
Re: A DWIM too far?
by Abigail-II (Bishop) on Jun 20, 2004 at 16:20 UTC
    Well, yes, of course. And I should have know, because that's classical idiom. I'm just going to blame YAPC. 12 hours of sleep in 3 nights.

    Abigail (Conferences and Perlmonks don't mix)

Re^3: A DWIM too far?
by ysth (Canon) on Jun 23, 2004 at 07:49 UTC
    That may not work for directories.

    But I think that idiom justifies Unix's choice of rename behavior. If rename failed when a new file already exists, there isn't good way to code a rename-that-overwrites.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2014-07-30 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls