in reply to Perl rename method

chdir($startdir) should be outside the loop, shouldn't it?

However, I'd look at a rewrite using File::Find or File::Find::Rule. The latter especially simplifies the task:

use File::Find::Rule; my $start = shift || '.'; for my $oldname ( File::Find::Rule->file->in( $start ) ) { ( my $newname = $oldname ) =~ s/\..*?$//; rename $oldname, "$newname.xml" or die "..."; }