In case you have no clue why something doesn't work, just add debug print statements everywhere, so you can see what is the problem.
My guesses are: file1.htm is not in $ENV{DOCUMENT_ROOT}, or your webdaemon user (apache, www, nobody...) doesn't have sufficient rights to write to $ENV{DOCUMENT_ROOT}
Besides that, you can also skip the chdir()
command and try it with the use of full path names in the rename() command. Something like:
$a = "$ENV{DOCUMENT_ROOT}/file1.htm";
$b = "$ENV{DOCUMENT_ROOT}/file2.htm";
rename($a, $b) || die "Uh oh, can't rename: $!";
--
b10m
All code is usually tested, but rarely trusted.