use strict; use warnings; use diagnostics; use autodie; use File::Copy::Recursive qw( rcopy ); use File::Path qw( mkpath remove_tree ); use File::Glob qw( :globally ); use File::Find; use File::Spec; use Getopt::Long; use Pod::Usage; use POSIX qw(strftime); use File::Spec::Functions; #Set command line arguments my ($website, $old_ip, $new_ip) = @ARGV; #Set vars my $TIMESTAMP = strftime("%Y%m%d%H%M", localtime); #my $volume = 'C:/'; my $SourceDir = File::Spec->catfile((qw(C: Users st2641 Desktop Source_dir))); my $destinationDir = File::Spec->catfile(qw(C: Users st2641 Desktop), $website); my $ARCHIVE = File::Spec->catfile(qw(C: Users st2641 Desktop), join('_', $website, $old_ip, $TIMESTAMP)); my @WEBSITES = qw( three five calnet-test ); my $file; my @errors; my @file_list; sub DirCompare{ my ( %old_list, %new_list, @diffs); ###for my $file ($ARCHIVE) { ###$old_list{$file} = 1; ###} #////New piece of code for my $file ( find ( sub { $new_list { $file } = 1 }, $SourceDir ) ); for my $file (keys %old_list) { if ( !exists $new_list{$file} ) { push @diffs, "Old file not in new: $file"; } } for my $file (sort keys %new_list) { if ( !defined $old_list{$file} ) { push @diffs, "Old file not in new: $file"; } } if (@diffs) { my $msg = sprintf "WARNING: %s\n", join "\nWARNING: ", @errors; check_ok( $msg ); } return; } $file (find( sub {$new_list{$file} = 1}, $SourceDir ) );