我正在創建一個Perl腳本來部署webcode(Windows 2008 Server)。我需要首先複製目標文件夾中的所有舊文件,併爲存檔目錄名稱(arc_dir.20131217)上的時間戳結尾創建文件的存檔目錄。將文件移入存檔。然後我需要將源代碼中的代碼複製到目標文件夾中。然而,它根本不起作用,而且我爲什麼無能爲力。Perl webcode部署腳本
兩件事情,我很熟悉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;