What is ctime (it's not a perl built-in)?
You code looks like it should work.
You should check what finalProcess returns, and you should also check rename for failure.
MJDsays "you can't just make shit up and expect the computer to know what you mean, retardo!"