Just a couple of comments if you don't mind. (I knew you wouldn't :-)Of course not, that's how I keep on learning! :)
Can you expand on this a little? Is this a performance issue or a "it might not do what you think it does" issue?Due to way some file systems work I would store the file names in an array and use the array to rename the files instead of renaming them in the File::Find::find() sub.
For fun and education, I rewrote it using glob(). It no longer recurses. I also changed the command line parameters so you can do the following:
rename.pl /home/dir rename.pl '/home/dir/*.txt'
Note that I had to quote the second example so that my shell does not interpret the * ...
#!/usr/bin/perl -w
use strict;
my $files=$ARGV[0]; $files='./*' if (!defined $files);
foreach my $old (glob($files)) {
next if (!-f $old);
my $new=$old; if ($new=~s/-\d-\d(\.\S{3})$/$1/) {
rename $File::Find::name, $new or warn "Could not rename $File::Find::name: $!";
}
}
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]