What do you mean by "doesn't work"?
I cannot think of any reason this would give you a problem. My instincts say something else is going on.
- How are you renaming the files?
- How are you executing the scripts?
- What is the exact output you are getting?
- What version of Perl are you using?