12.4. Rename files

  • glob - directory listing

Example 12-2. examples/shell/rename_files.pl

#!/usr/bin/perl
use strict;
use warnings;

foreach my $file (glob "*.xml") {
    my $new = substr($file, 0, -3) . "html";
    print "rename $file, $new\n";
    #rename $file, $new;
}

If you are interested in on-site trainings by the author, please contact me directly.

Online courses: