, - :
use File::Copy;
sub construct_filename {
my ($dir, $name, $counter) = @_;
if ($name =~ /^(.*)\.(.*)$/) {
return "$dir/$1.$counter.$2";
} else {
return "$dir/$name.$counter";
}
}
if (-e "$destination$filename") {
$counter = 1;
while (-e construct_filename($destination,$filename,$counter)) {
$counter++;
}
move("/tmp/$filename", construct_filename($destination,$filename,$counter));
} else {
move("/tmp/$filename", "$destination$filename");
}
, perl ., +. , , . , .
, , , (, "$destination/$filename"). , File::Spec. , , , , , ; . File::Spec !