#!/opt/perl5/bin/perl -w use strict; use File::Slurp; # The production files will be listed in # the source hashes my $report = "/home/mis/tstanley/SourceDiff.rpt"; my %input = ( iqs_source => '/dsmpayroll/iqs-source', prg_source => '/dsmpayroll/prg-source', spg_source => '/dsmpayroll/spg-source', tpr_source => '/dsmpayroll/tpr-source', iqs => '/dsmmigrate/development/iqs', prg => '/dsmmigrate/development/prg', spg => '/dsmmigrate/development/spg', tpr => '/dsmmigrate/development/tpr', ); my %data; foreach my $key (keys(%input)) { my $dir = $input{$key}; chdir($dir); foreach my $file (read_dir('.')) { my $sum = `sum $file`; my ($x) = split(/\s+/, $sum); $data{$key}{$file} = $x; } } ## Open the report file ... #### #!/opt/perl5/bin/perl -w use strict; # The production files will be listed in # the source hashes my $report = "/home/mis/tstanley/SourceDiff.rpt"; sub DEV () { 0 } sub PROD () { 1 } my %input = ( IQS => [ '/dsmmigrate/development/iqs', '/dsmpayroll/iqs-source' ], PRG => [ '/dsmmigrate/development/prg', '/dsmpayroll/prg-source' ], SPG => [ '/dsmmigrate/development/spg', '/dsmpayroll/spg-source' ], TPR => [ '/dsmmigrate/development/tpr', '/dsmpayroll/tpr-source' ], ); ## Open the report file open RPT, ">$report" or die "Unable to open $report: $!\n"; my $date=`date`; print RPT "$date\n\n"; ## For each set of directories, we find the common file names in them, ## and then go through those files and compare the sums. If the ## Production file is different, we write it out to the report file. my $print_seperator; # False for first loop iteration. foreach my $key (sort keys %input) { local *DH; my $dir; my $file; my %dev_crcs; my %prod_crcs; $dir = $input{$key}[DEV]; opendir(DH, $dir) or die "Unable to open dir $dir: $!\n"; while (defined($file = readline(DIR))) { next if $_ eq '.'; next if $_ eq '..'; next if $_ eq 'cob'; next if substr($_, -4) eq '.ffl'; next if substr($_, -4) eq '.lst'; $dev_crcs{$file} = 0+`sum $dir/$file`; } $dir = $input{$key}[PROD]; opendir(DH, $dir) or die "Unable to open dir $dir: $!\n"; while (defined($file = readline(DIR))) { next if $_ eq '.'; next if $_ eq '..'; next if substr($_, -4) eq '.ffl'; next if substr($_, -4) eq '.lst'; $prod_crcs{$file} = 0+`sum $dir/$file`; } if ($print_seperator) { print RPT "\n\n"; } else { # True for all but first loop iteration. $print_seperator = 1; } print RPT "$key Source Files\n"; print RPT ("=" x length($key)) . "=============\n"; foreach $file (keys(%dev_crcs)) { if (exists($prod_crcs{$file}) && $prod_crcs{$file} != $dev_crcs{$file}) { print RPT "$dir/$file\n" } } }