use warnings; use strict; while () { if (/(\w+)=\w+ (\w+)=/) { my $diff = hex($2) - hex($1); printf "0x%x %d\n", $diff, $diff; } } __DATA__ 0x405d75=inst1 0x405d7a=inst2