in reply to Trying to rename files in directory
Have you printed out the source and target file names to see if they really are what they should be?
One problem could be that basename strips the directory component, so the source file ($temp_f_name) wouldn't be found in case the script is called from outside of the directory /my_dir.
Also, rename(...) unless ... or warn ... probably doesn't do what you expect. I suppose you meant
unless ($temp_f_name eq $renamed_file) { rename($temp_f_name, $renamed_file ) or warn "Couldn't rename: +$!\n"; }
|
|---|