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

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -