Your program, as presented, will not work.   Suppose that File::Find::find created a list something like:


After you rename '/home/transiency/dir*one' to '/home/transiency/dirone' then your program will not be able to find and rename '/home/transiency/dir*one/file*one' and '/home/transiency/dir*one/file*two' because '/home/transiency/dir*one' does not exist anymore.   You need something like:

#!/usr/bin/perl use warnings; use strict; use File::Find; our $VERSION = '0.1.3'; ### NAME NORMALIZER ### my $DIR = shift @ARGV; opendir TOCLEAN, $DIR or die "$DIR: $!"; my @dirs = map "$DIR/$_", grep -d "$DIR/$_" && !/\A\.\.?\z/, readdir T +OCLEAN; finddepth sub { ( my $new = $_ ) =~ tr!a-zA-Z0-9.~-!_!c; return if $new eq $_; rename $_, $new or warn "Cannot rename '$_' to '$new' $!"; }, @dirs;

In reply to Re: File::Find finding . and .. by jwkrahn
in thread File::Find finding . and .. by transiency

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":