Can I trust Perl to rename before I overwrite? -


can trust rename done before put new file in old location? if not better way this? (-e test.old) make sure it's been moved or unnecessary?

rename("test", "test.old") || die "can't rename test";  open(file, ">test") || die "can't write test"; print file "foo"; close(file); 

there many things can make rename fail, addition of if (-e "test") { die "file not renamed beforehand!\n" } cheap insurance policy.

in case, can not think of reason rename fail without triggering die condition have, if overwrite catastrophic disk read safeguard still worth it.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -