Я создаю скрипт Perl для развертывания веб-кода (Windows 2008 Server). Мне нужно сначала скопировать все старые файлы из папки назначения и создать архив dir для файлов с временной меткой, завершающей имя архивного dir (arc_dir.20131217). Переместите файлы в архив. Затем мне нужно скопировать код из исходного каталога в папку назначения. Однако он не работает вообще, и я абсолютно не знаю, почему.Perl webcode deploy script
Две вещи, я очень зелёный с Perl, как будет вскоре видно, и я не хочу, чтобы кто-то делал код для меня. Это отчасти поражает цель обучения. Направление и диалог были бы замечательными. Я мечта ветеранов, желающих учиться, и я хочу писать только чистый код.
use strict;
use warnings;
use autodie;
use File::Copy; #Gives you access to the "move" command
use File::Path; #Copies data recursively from one dir and creates a new dir
use POSIX;
#Set Directories
use constant {
TIMESTAMP => strftime("%Y%M%d%H%M%S", localtime);
Source_Dir => "C:\Users\Documents\Source_Dir",
destination_Dir => "C:\Users\Documents\Destination_Dir",
ARCHIVE => "C:\Users\Documents\arc_dir.TIMESTAMP",
};
#Creates new directory to archive old files
make_path('C:\Users\Shaun\Documents\arc_dir.TIMESTAMP');
#Need to copy destination dir, create archive dir and paste data to it
#Opens destination_Dir, so I can read from it
opendir my $dir, destination_Dir;
# Loop through directory and grab all of the files and store in var
while (my $file = readdir $dir) {
my $destination_Dir = destination_Dir . "/" . "$file";
move $destination_Dir, ARCHIVE;
#Loop through directory and copy all webcode to destination_Dir
opendir my $dir, Source_Dir;
while (my $file = readdir $dir) {
my $Source_Dir = Source_Dir . "/" . "$file";
move $Source_Dir, destination_Dir;