#!/usr/bin/perl use strict; use Data::Dumper; my $f1=shift; my $f2=shift or die("usage $0 f1 f2\m"); my $mat = do("CM.dumper") || {}; my $tmp = "_ocr_$$"; system("grep -o . $f1 > $tmp-1"); system("grep -o . $f2 > $tmp-2"); #open( F, "diff --side-by-side $tmp-1 $tmp-2|") or die; open( F, "diff -y -W 30 $tmp-1 $tmp-2|") or die; while(){ chomp; my @a=split(/\t+/, $_); if (scalar @a == 2) { $mat->{$a[0]}{$a[1]} ++} else { $mat->{$a[0]}{$a[2]} ++} } open(D,">CM.dumper"); print D Dumper($mat); close D; unlink ("$tmp-1", "$tmp-2",);