#!perl                                                      #<HTML><PRE>
# ======================================================================
  if (scalar(@ARGV)<1) {
    die "Arguments (paths) missing. Error";
  }
  opendir(LU,$ARGV[0]) || die "Directory '$ARGV[0]' not found. Error";
  @DIR1=readdir(LU);
  closedir(LU);
  opendir(LU,$ARGV[1]) || die "Directory '$ARGV[1]' not found. Error";
  @DIR2=readdir(LU);
  closedir(LU);
#
  foreach $NAME1 (@DIR1) {
    $PATH1=$ARGV[0].$NAME1;
    unless ($NAME1 eq '.') {
      unless ($NAME1 eq '..') {
        unless (-d $PATH1) {
          foreach $NAME2 (@DIR2) {
            $PATH2=$ARGV[1].$NAME2;
            if ($NAME1 eq $NAME2) {
              open(LU,$PATH1) || die "Cannot open '$PATH1'. Error";
              @FILE1=<LU>;
              close(LU) || die "Error";
              open(LU,$PATH2) || die "Cannot open '$PATH2'. Error";
              @FILE2=<LU>;
              close(LU) || die "Error";
#             Check for the number of lines:
              if (scalar(@FILE1)==scalar(@FILE2)) {
#               Check for the contents:
                foreach $LINE1 (@FILE1) {
                  $LINE2=shift(@FILE2);
                  if ($LINE1 ne $LINE2) {
                    print "$NAME1: different lines\n";
                    goto EndCheck;
                  }
                }
                print "$NAME1: identical - deleted\n";
#               *** Very dangerous command ***
                unlink($PATH2);
#               ******************************
                EndCheck:
              } else {
                print "$NAME1: different number of lines\n";
              }
            }
          }
        }
      }
    }
  }
# ======================================================================
1;                                                               #</PRE>
