A warning about glob(). The default version is based on the C-shell and breaks on whitespace. If your files have spaces in their names, use the BSD version from File::Glob.
#!/usr/bin/perl
use strict;
use warnings;
use File::Glob qw( :bsd_glob );
foreach my $file (glob "*.xml") {
my $new = substr($file, 0, -3) . "html";
rename $file, $new;
}
Authored Comments
A warning about glob(). The default version is based on the C-shell and breaks on whitespace. If your files have spaces in their names, use the BSD version from File::Glob.
#!/usr/bin/perl
use strict;
use warnings;
use File::Glob qw( :bsd_glob );
foreach my $file (glob "*.xml") {
my $new = substr($file, 0, -3) . "html";
rename $file, $new;
}
For anyone using revision control, not just admins.
1. Add a critic to checkin. A critic not only checks syntax but for common bugs.
2. Add a tidy to checkin. It reformats the code into The Style. That way, developers don't have to waste time making conform to The Style.