A few things:
First off, use the File::Find module to recursively plow through directories. It is MUCH easier to work with than rolling your own script, and comes bundled with every version of perl.
Secondly, use strict and -w. They will help you write clean code, catch typos, and make your life easier.
Thirdly, on to your problem. I've rewritten your code to this: (using File::Find, strict, and -w)
#!perl -w use strict; use File::Find; my $path = $ARGV[0]; my $ct = 0; find (\&wanted, $path); print "Number of files changed: ", $ct, "\n"; sub wanted { if ($_ ne lc($_)) { my $newname = lc($_); rename ($File::Find::name, $File::Find::dir . $newname); print $_, " was changed to ", $newname, "\n"; $ct++; } }
If you have any questions about the above code, please reply so that we can clear up any everything.
In reply to Re: Renaming Sub Dir/Files.
by jryan
in thread Renaming Sub Dir/Files.
by JoeCool
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |