in reply to Copy and Rename file at destination directory
You should try:copy( "$dir\\$file", "C:\\testfiles\\$file" ) or die "Failed to copy $file: $!\n"; rename $file, $newfile
But have you ever tried this:copy( "$dir\\$file", "C:\\testfiles\\$file" ) or die "Failed to copy $file: $!\n"; rename "C:\\testfiles\\$file", "C:\\testfiles\\$newfile";
Question: What will happen if you copy more than one file from $dir?copy( "$dir\\$file", "C:\\testfiles\\$newfile" ) or die "Failed to copy $file: $!\n";
Answer: You will end up with just one $newfile.
Then regarding your not-shifted $newfile parameter to your sub. Instead of shifting a sub's parameters I prefer to write:
sub process_dir { my ($dir, $newfile) = @_;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Copy and Rename file at destination directory
by Skyler99 (Novice) on Jun 04, 2003 at 12:36 UTC | |
by nimdokk (Vicar) on Jun 04, 2003 at 12:52 UTC |