TStanley has asked for the wisdom of the Perl Monks concerning the following question:
#!/opt/perl5/bin/perl -w use strict; use File::Slurp; # The production files will be listed in # the source hashes my (%iqs,%iqs_source,%prg,%prg_source); my (%spg,%spg_source,%tpr,%tpr_source); my $report="/home/mis/tstanley/SourceDiff.rpt"; ## Read each directory and get the file names my @iqs_src=read_dir('/dsmpayroll/iqs-source'); my @iqs=read_dir('/dsmmigrate/development/iqs'); my @prg_src=read_dir('/dsmpayroll/prg-source'); my @prg=read_dir('/dsmmigrate/development/prg'); my @spg_src=read_dir('/dsmpayroll/spg-source'); my @spg=read_dir('/dsmmigrate/development/spg'); my @tpr_src=read_dir('/dsmpayroll/tpr-source'); my @tpr=read_dir('/dsmmigrate/development/tpr'); ## Change into each directory and go through the files ## and get the sum of each file and put into a hash chdir('/dsmpayroll/iqs-source'); foreach(@iqs_src){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $iqs_source{$_}=$x; } chdir('/dsmpayroll/prg-source'); foreach(@prg_src){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $prg_source{$_}=$x; } chdir('/dsmpayroll/spg-source'); foreach(@spg_src){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $spg_source{$_}=$x; } chdir('/dsmpayroll/tpr-source'); foreach(@tpr_src){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $tpr_source{$_}=$x; } chdir('/dsmmigrate/development/iqs'); foreach(@iqs){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $iqs{$_}=$x; } chdir('/dsmmigrate/development/prg'); foreach(@prg){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $prg{$_}=$x; } chdir('/dsmmigrate/development/spg'); foreach(@spg){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $spg{$_}=$x; } chdir('/dsmmigrate/development/tpr'); foreach(@tpr){ my $sum=`sum $_`; my ($x,$y,$z)=split /\s+/,$sum; $tpr{$_}=$x; } ## Open the report file open RPT,">$report"||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. print RPT "IQS Source Files\n"; print RPT "================\n"; my @iqs_common; foreach(keys %iqs){ next if $_=~/cob/; ## This is an empty directory that exists in each + source directory push(@iqs_common,$_) if exists $iqs_source{$_}; } foreach(@iqs_common){ next if $_=/\.ffl|\.lst/; ## If a file has these extensions, they ca +n be ignored my $prod=$iqs_source{$_}; my $dev=$iqs{$_}; next if !defined $prod and !defined $dev; ## Error handling if all f +iles match or can be ignored if ($prod != $dev){ print RPT "/dsmpayroll/iqs-source/$_\n"; } } print RPT "\n\nPRG Source Files\n"; print RPT "================\n"; my @prg_common; foreach(keys %prg){ next if $_=~/cob/; ## This is an empty directory that exists in each + source directory push(@prg_common,$_) if exists $prg_source{$_}; } foreach(@prg_common){ next if $_=~/\.ffl|\.lst/; ## If a file has these extensions, they c +an be ignored my $prod=$prg_source{$_}; my $dev=$prg{$_}; next if !defined $prod and !defined $dev; ## Error handling if all f +iles match or can be ignored if($prod != $dev){ print RPT "/dsmpayroll/prg-source/$_\n"; } } print RPT "\n\nSPG Source Files\n"; print RPT "================\n"; my @spg_common; foreach(keys %spg){ next if $_=~/cob/; ## This is an empty directory that exists in each + source directory push(@spg_common,$_) if exists $spg_source{$_}; } foreach(@spg_common){ next if $_=~/\.ffl|\.lst/; ## If a file has these extensions, they c +an be ignored my $prod=$spg_source{$_}; my $dev=$spg{$_}; next if !defined $prod and !defined $dev; ## Error handling if all f +iles match or can be ignored if($prod != $dev){ print RPT "/dsmpayroll/spg-source/$_\n"; } } print RPT "\n\nTPR Source Files\n"; print RPT "================\n"; my @tpr_common; foreach(keys %tpr){ next if $_=~/cob/; ## This is an empty directory that exists in each + source directory push(@tpr_common,$_) if exists $tpr_source{$_}; } foreach(@tpr_common){ next if $_=~/\.ffl|\.lst/; ## If a file has these extensions, they c +an be ignored my $prod=$tpr_source{$_}; my $dev=$tpr{$_}; next if !defined $prod and !defined $dev; ## Error handling if all f +iles match or can be ignored if($prod != $dev){ print RPT "/dsmpayroll/tpr-source/$_\n"; } } close RPT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File Differences
by ikegami (Patriarch) on May 31, 2005 at 16:39 UTC | |
|
Re: File Differences
by tlm (Prior) on May 31, 2005 at 16:43 UTC | |
by TStanley (Canon) on May 31, 2005 at 17:07 UTC | |
by lupey (Monk) on May 31, 2005 at 18:43 UTC | |
|
Re: File Differences
by davido (Cardinal) on May 31, 2005 at 16:35 UTC | |
|
Re: File Differences
by TedPride (Priest) on May 31, 2005 at 17:26 UTC | |
|
Re: File Differences
by TStanley (Canon) on Jun 07, 2005 at 16:57 UTC |