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
Post a Comment