On Mon, Jul 07, 2003 at 11:45:34AM -0400, Paul Kraus wrote: > I am doing a readdir. > Taking the filenames that are found and trying to rename them. > > Opendir > @files = Readdir > > Foreach @files > parse filename > $newfile = newfile name based on parsed name > push (@rename,[$_,$newfile]) > > Foreach @rename > rename $$_[0], $$_[1] or die ("NO $!\n") > > I guess I could send all the code but that is pretty much what is taking > place. > I have tried to add a closedir before the @rename loop but it does > nothing.
Well you might try something like this (this would append '.old' to each filename. Modify as appropriate): use File::Basename; @old = glob('path/to/files/*'); # don't forget the '*' !! @old = map { basename($_} } @old; # strip off the directory part @new = map { "$_.old" } @old; # Get the new versions while (@old) { rename( shift @old, shift @new ) or die "NO $!"; } Of course, this can be collapsed a bit: use File::Basename; do{ $f=basename($_}; rename( $f, "$f.old" ) or die "NO $!"} for glob('path/to/files/*'); --Dks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]