my $expected = "a1 a2 a3 b1 b2 c1 d1 f1 f1 f1 g1 g2";
my $computed = "a1 a3 b1 b2 c1 c2 e1 f1 f1 g2 g1";
my $lastColumn = 1;

&match($expected, $computed, 0, 1);

sub match {
	my ($expected, $computed, $column) = @_;
	my $indent = "\t" x $column;
	my %keys; map ($keys{substr($_, $column, 1)}++, split(/ /, "$expected $computed"));
	my @keys = sort keys %keys;
	print "$indent column $column keys: @keys\n";
	
	for $key (@keys) {
		my @e = grep($key eq substr($_, $column, 1), split(/ /, $expected));
		my @c = grep($key eq substr($_, $column, 1), split(/ /, $computed));
		print "$indent key $key expects: @e, computes: @c\n";
		
		if ($#e < 0 or $#c < 0) {
			print "$indent	missing: @e, surplus: @c\n";
		} elsif ($column < $lastColumn) {
			&match ("@e", "@c", $column+1);
		} elsif ($#e == 0 and $#c == 0) {
			print "$indent	compare cells of @e and @c\n";
		} else {
			print "$indent	can't distinguish @e and @c\n";
		}
	}
}
