in reply to rename doesn't work on OSX?
permissions is a good guess, but
rename($file, $newfile) || print "Rename $file to $newfile failed: + $!.\n"; [download]
will give you a lot more information including what the system thinks the problem is.