ArifS has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; my $existingFile; my $filename; print "provide filename: "; $existingFile = <STDIN>; $filename = "folder1"; chomp $existingFile; chomp $filename; if (-e $filename) { print "File Exists! Renaming with .[x]\n"; my $counter++; rename "$existingFile", "$filename.[$counter]"; } else { rename "$existingFile", "$filename"; } exit;
It does the first 1, as folder1.1, but doesn't do the 2nd, 3rd, or 4th etc.OUTPUT provide filename: folder1 - Copy File Exists! Renaming with .[x]
|
|---|