http://www.perlmonks.org?node_id=953827


in reply to Trying to rename files in directory

I could be wrong but try it without the "eg" in the substitution:
s/^([^_]+_)(.*)(\.\w{3,4})\z$/$3/;
And then change your warning to:
warn "Couldn't rename $temp_f_name to $renamed_file, $!\n";
to see what else is happening. If that's no good put in
print "About to rename $temp_f_name to $renamed_file\n";
before the rename()