#!/bin/perl

$tmp="cmp_diff_log.txt";
$fp_bool = open(FPW, ">>$tmp") || die("open fail $tmp\n");

$cmd="cmp "     . $ARGV[0] . " " . $ARGV[1] . $ARGV[0];
#$cmd="cmp -s " . $ARGV[0] . " " . $ARGV[1] . $ARGV[0] . "|| echo diff";

#print("$cmd\n");
#check if ignore directory is in the search string
if($ARGV[2] ne "") {
  $pp=index($ARGV[0], $ARGV[2]);
}
else { $pp=-1; }
if($pp == -1) {
  $file=$ARGV[1] . $ARGV[0];
  if(-e $file) {
    $dis=`$cmd`;
    if(length($dis) > 0) {
      $cmd="diff -w " . $ARGV[0] . " " . $ARGV[1] . $ARGV[0];
     #print("$cmd\n");
      $dis=`$cmd`;
      if(length($dis) > 0) {
        print FPW ("FILE $ARGV[0]\n----------------\n");
        print FPW ("$dis\n----------------\n");
      }
    }
  } else {
    print FPW ("FILE not exist $file\n");
  }
}
