karthik.raju has asked for the wisdom of the Perl Monks concerning the following question:
use File::DirCompare; use File::Basename; sub compare_dirs{ my ($dir1, $dir2) = @_; my $equal = 1; File::DirCompare->compare($dir1, $dir2, sub { my ($a,$b) = @_; $equal = 0; # if the callback was called even once, the dirs are n +ot equal if ( !$b ) { printf "File '%s' only exists in dir '%s'.\n", basename($a), dir +name($a); } elsif ( !$a ) { printf "File '%s' only exists in dir '%s'.\n", basename($b), dir +name($b); } else { printf "File contents for $a and $b are different.\n"; } }); return $equal; } print "Please specify two directory names\n" and exit if (@ARGV < 2); printf "%s\n", &compare_dirs($ARGV[0], $ARGV[1]) ? 'Test: PASSED' : 'T +est: FAILED';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script to compare 2 folders, including sub folders and files with content
by haukex (Archbishop) on Jul 02, 2016 at 11:49 UTC | |
by karthik.raju (Acolyte) on Jul 04, 2016 at 07:19 UTC | |
by haukex (Archbishop) on Jul 04, 2016 at 07:30 UTC | |
|
Re: Script to compare 2 folders, including sub folders and files with content
by afoken (Chancellor) on Jul 02, 2016 at 11:58 UTC | |
by duelafn (Parson) on Jul 02, 2016 at 14:14 UTC |