NewData(file 1) Puma 77777 33333 44444 55555 Adidas 99999 88888 55555 77777 22222 11111 33333 44444 Brooks 11111 22222 33333 44444 33333 44444 55555 66666 OldData(file 2) Puma 77777 33333 44444 55555 Adidas 11111 11111 33333 44444 99999 88888 55555 77777 Brooks 11111 22222 33333 44444 33333 44444 55555 66666 #### 'Adidas' => { 'y1' => [ '88888', '11111' ], 'x2' => [ '55555', '33333' ], 'y2' => [ '77777', '44444' ], 'x1' => [ '99999', '22222' ] }, 'Puma' => { 'y1' => [ '33333' ], 'x2' => [ '44444' ], 'y2' => [ '55555' ], 'x1' => [ '77777' ] }, 'Brooks' => { 'y1' => [ '22222', '44444' ], 'x2' => [ '33333', '55555' ], 'y2' => [ '44444', '66666' ], 'x1' => [ '11111', '33333' ] } }; #### $VAR1 = { 'Adidas' => { 'y1' => [ '11111', '88888' ], 'x2' => [ '33333', '55555' ], 'y2' => [ '44444', '77777' ], 'x1' => [ '11111', '99999' ] }, 'Puma' => { 'y1' => [ '33333' ], 'x2' => [ '44444' ], 'y2' => [ '55555' ], 'x1' => [ '77777' ] }, 'Brooks' => { 'y1' => [ '22222', '44444' ], 'x2' => [ '33333', '55555' ], 'y2' => [ '44444', '66666' ], 'x1' => [ '11111', '33333' ] } }; #### foreach my $newq (keys %hash1) { foreach my $oldq(keys %hash2) { if ( $newq eq $oldq) { foreach my $newx1(@{$hash1{$newq}{x1}}) { foreach my $oldx1(@{$hash2{$oldq}{x1}}) { if ($newx1 == $oldx1) { print "$newq\t$newx1\t$oldx1\n"; } if ($newx1 != $oldx1) { print "$newq\t$newx1\t$oldx1\n"; } } #### New Old Adidas 99999 99999 Puma 77777 77777 Brooks 11111 11111 Brooks 33333 33333 #### New Old Adidas 99999 11111 Adidas 22222 11111 Adidas 22222 99999 Brooks 11111 33333 Brooks 33333 11111 #### New Old x1 y1 x2 y2 x1 y1 x2 y2 Puma 77777 33333 44444 55555 77777 33333 44444 55555 Adidas 99999 88888 55555 77777 99999 88888 55555 77777 Brooks 11111 22222 33333 44444 11111 22222 33333 44444 Brooks 33333 44444 55555 66666 33333 44444 55555 66666 #### New Old x1 y1 x2 y2 x1 y1 x2 y2 Adidas 22222 11111 33333 44444 11111 11111 33333 44444