#!/usr/bin/perl
 
sub get_hex {
	my $filename = $_[0];
	my $size = (stat($filename))[7];
	my @buffer;
	my $remainder = ($size % 20);
	my $itterations = int($size / 20);
 
	open FILE, "<$filename";
	binmode FILE;
 
	my @hexfile;
 
	$count = 0;
	for($count = 0; $count < $itterations; $count++) {
		read(FILE, $buffer[$count], 20, ($count * 20));
		$buffer[$count] = substr($buffer[$count], ($count * 20), 20);
 
		foreach (split(//, $buffer[$count])) {
			$hexfile[$count] = $hexfile[$count] . (unpack "H*", $_) . " ";
		}
		$hexfile[$count] = $hexfile[$count] . "\n";
	}
 
	read(FILE, $buffer[$count], $remainder, ($count * 20));
	$buffer[$count] = substr($buffer[$count], ($count * 20), $remainder);
 
	foreach (split(//, $buffer[$count])) {
		$hexfile[$count] = $hexfile[$count] . (unpack "H*", $_) . " ";
	}
	$hexfile[$count] = $hexfile[$count] . "\n";
 
	close(FILE);
 
	@hexfile;
}
 
my @hex1 = &get_hex($ARGV[0]);
my @hex2 = &get_hex($ARGV[1]);
 
for ($count = 0; $count < @hex1; $count++) {
	if("$hex1[$count]" ne "$hex2[$count]") {
		my $start = sprintf("%x", ($count * 20));
		print "@@ -$start @@\n";
		if("$hex1[$count]" eq ""){
			print "-\n";
		} else {
			print "-$hex1[$count]";
		}
		if("$hex2[$count]" eq ""){
			print "+\n";
		} else {
			print "+$hex2[$count]";
		}
	}
}