in reply to Re^2: Comparing files in directory
in thread Comparing files in directory
Providing there are no sub-folders, the essentials are this
poj#!perl use strict; use File::Find; my $old = 'c:/....'; # as reqd my $new = 'c:/....'; # as reqd my %old_list =(); my %new_list =(); find( sub { $old_list{$_} = 1}, $old); find( sub { $new_list{$_} = 1}, $new); my $diffs = DirCompare(); print "$_\n" for @$diffs; sub DirCompare { my @diffs = (); for my $file (sort keys %old_list) { if ( !defined $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, "New file not in old: $file"; } } return \@diffs; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Comparing files in directory
by smturner1 (Sexton) on Dec 11, 2014 at 21:03 UTC | |
by poj (Abbot) on Dec 11, 2014 at 21:22 UTC |