Eventually I will put more Perl related information here.
For the time being, I made a number of howto documents.
Rename files.
Here is a brilliant program for renaming one or more files according to a specified Perl expression. I found it on page 706 of Programming Perl (3rd edition).
#!/usr/bin/perl $op = shift; for( @ARGV ) { $was = $_; eval $op; die if $@; rename( $was, $_ ) unless $was eq $_; }In the code above, the second last line calls the built-in function "rename", not the program itself (which is named "rename.pl"). Below are a few examples of use.% rename.pl 's/\.htm/\.html/' *.htm # append an 'l' % rename.pl '$_ .= ".old"' *.html # append '.old' % rename.pl 'tr/A-Z/a-z/' *.HTML # lowercase % rename.pl 'y/A-Z/a-z/ unless /^Make/' * # lowercase