Random note: you might want to look at the File::Spec module instead of dealing with path separators directly. Also, the File::Basename module might come in handy.
WRT your problem, couldn't you just add a couple of lines to your process_dir() routine that checks to see if the file is there and if so, slightly modifies the output filename? Something like this (untested):
use File::Basename; use File::Spec::Functions; # ... while (my $file = readdir DIR) { # ... # $newfile contains the full path to the new file my $extra = "a"; while (-e $newfile) { my ($path,$basename,$suffix) = fileparse($newfile,'.rtf'); $basename .= $extra; $extra++; $newfile = catfile($path,$basename,$suffix); } copy($oldfile,$newfile) or die; }
In reply to Re: Duplicate Number in a file
by duff
in thread Duplicate Number in a file
by skyler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |