Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: File Differences

by TStanley (Canon)
on Jun 07, 2005 at 16:57 UTC ( [id://464393]=note: print w/replies, xml ) Need Help??


in reply to File Differences

I finally was able to sit down last night at home and do a re-write of the script. I present to you, a much cleaner and shorter version:
#!/opt/perl5/bin/perl -w use strict; use File::Slurp; my %data; # Report names/locations my $reportA="/home/mis/tstanley/SourceDiff.rpt"; my $reportB="/home/mis/tstanley/ADevFiles.rpt"; my $reportC="/home/mis/tstanley/AProdFiles.rpt"; my %input = (iqs =>"/dsmmigrate/development/iqs", iqs_source =>"/dsmpayroll/iqs-source", prg =>"/dsmmigrate/development/prg", prg_source =>"/dsmpayroll/prg-source", spg =>"/dsmmigrate/development/spg", spg_source =>"/dsmpayroll/spg-source", tpr =>"/dsmmigrate/development/tpr", tpr_source =>"/dsmpayroll/tpr-source", idsii_decharge =>"/dsmmigrate/development/idsii/decharge", idsii_decharge_source =>"/dsmpayroll/idsii/decharge-source", ufas_decharge =>"/dsmmigrate/development/ufas/decharge", ufas_decharge_source =>"/dsmpayroll/ufas/decharge-source", ufas_recharge =>"/dsmmigrate/development/ufas/recharge", ufas_recharge_source =>"/dsmpayroll/ufas/recharge-source", idsii_dml_fixed =>"/dsmmigrate/development/idsii/dml/fixed-utilities" +, idsii_dml_fixed_source=>"/dsmpayroll/idsii/dml/fixed-utilities", idsii_dml_salesmstr =>"/dsmmigrate/development/idsii/dml/SALES-MS +TR/ source", idsii_dml_salesmstr_source=>"/dsmpayroll/idsii/dml/SALES-MSTR/ +source", idsii_dml_bisschema =>"/dsmmigrate/development/idsii/dml/BIS-SCHE +MA/ source", idsii_dml_bisschema_source=>"/dsmpayroll/idsii/dml/BIS-SCHEMA/ +source", reload_ufas_file=>"/dsmmigrate/development/reload/ufas/source- +file", reload_ufas_file_source=>"/dsmpayroll/reload/ufas/source-file" +, reload_ufas_table=>"/dsmmigrate/development/reload/ufas/source-table" +, reload_ufas_table_source=>"/dsmpayroll/reload/ufas/source-tabl +e", reload_ufas_table_1226=>"/dsmmigrate/development/reload/ufas/s +ource-table/12262004_SAVE", reload_ufas_table_1226_source=>"/dsmpayroll/reload/ufas/source +-table/12262004_SAVE", ufas_dml=>"/dsmmigrate/development/ufas/dml/source", ufas_dml_source =>"/dsmpayroll/ufas/dml/source", ufas_dml_fixed =>"/dsmmigrate/development/ufas/dml/fixed-utilities", ufas_dml_fixed_source=>"/dsmpayroll/ufas/dml/fixed-utilities"); # Get the sum of each file within the directories foreach my $key(keys %input){ print "$input{$key}\n"; chdir($input{$key}); my @files=read_dir($input{$key}); foreach my $file(@files){ my $sum=`sum $file`; my ($x,$y)=split /\s+/,$sum; $data{$key}{$file}=$x; } } # Open the report files my $date=`date`; open RPTA,">$reportA"||die "Unable to open $reportA: $!\n"; open RPTB,">$reportB"||die "Unable to open $reportB: $!\n"; open RPTC,">$reportC"||die "Unable to open $reportC: $!\n"; print RPTA "Date: $date\n"; print RPTB "Date: $date\n"; print RPTC "Date: $date\n"; # Dynamically get the keys for the reports my @Keys; foreach(sort keys %input){ push (@Keys,$_) if $_ !~ /_source/; } # Generate the reports for each directory foreach(@Keys){ generate($_); } sub generate{ my $dev_key=shift; my $prod_key="$dev_key"."_source"; my (@dev_only,@prod_only); my (%seen_dev,%seen_prod); my (@common,$item); my @DEV=keys %{$data{$dev_key}}; my @PROD=keys %{$data{$prod_key}}; foreach $item(@DEV){ $seen_dev{$item}=1; } foreach $item(@PROD){ $seen_prod{$item}=1; } foreach(keys %seen_dev){ next if $_=~/cob/; push(@common,$_) if exists $seen_prod{$_}; } foreach(@DEV){ unless($seen_prod{$_}){ push(@dev_only,$_); } } foreach(@PROD){ unless($seen_dev{$_}){ push(@prod_only,$_); } } print RPTA "\n$dev_key Source Files\n"; print RPTA "===================\n"; foreach(@common){ next if $_=~/\.ffl|\.lst/; my $prod=$data{$prod_key}{$_}; my $dev=$data{$dev_key}{$_}; next if !defined $prod and !defined $dev; if ($prod != $dev){ print RPTA "$input{$prod_key}/$_\n"; } } print RPTB "\n$dev_key Development Only\n"; print RPTB "=========================\n"; foreach(@dev_only){ next if $_=~/\.deps|\.cob|\.gnt|\.ffl|\.lst/; print RPTB "$input{$dev_key}/$_\n"; } print RPTC "\n$dev_key Production Only\n"; print RPTC "=======================\n"; foreach(@prod_only){ print RPTC "$input{$prod_key}/$_\n"; } } close RPTA; close RPTB; close RPTC;

TStanley
--------
The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://464393]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-20 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found