#! /usr/bin/perl -w use File::Find; use File::Basename; use strict; @ARGV == 2 or die "Usage: $0 dir1 dir2 \n"; my $filename; my $base; my @list; my %hash1; my %hash2; my $key; sub getsource { $filename = $File::Find::name; if( $filename =~ /\.c$/ || /\.cpp$/ || /\.h$/ || /\.tcl$/ ){ push @list, $filename; } } my $dir1 = $ARGV[0]; my $dir2 = $ARGV[1]; find (\&getsource, $dir1); foreach $filename (@list) { $base = basename($filename); $hash1{$base} = $filename; } @list = (); find (\&getsource, $dir2); foreach $filename (@list) { $base = basename($filename); $hash2{$base} = $filename; } foreach $key (keys %hash1) { if (!exists($hash2{$key})) { printf "$key does not exist in $dir2\n"; next; } my $difference = `diff -q $hash1{$key} $hash2{$key}`; next unless $difference; my $detail = `diff $hash1{$key} $hash2{$key}`; $detail =~ s/.*static char \*cvsid="\$Id:.*//g; $detail =~ s/2c2|1c1//; $detail =~ s/---//; next unless $detail =~ /\w/; print $difference; } =head1 NAME dircmp.pl dir1 dir2 =head1 DESCRIPTION Compare *.c *.cc *.h *.tcl files in two directories, specifically to help CVS users to manage branches. =head1 README Report the names of source code files that have different content. Report the files existing in dir1 but missing from dir2. User can add more extensions to match *.f *.hh or anything else. Ignore CVS comments. =head1 PREREQUISITES requires strict module and File module =head1 SCRIPT CATEGORIES Web =cut