use warnings; use strict; my @a1 = ( { name => 'orange', fruit => 'yes', vegetable => 'no', count => 50 }, { name => 'squash', fruit => 'no', vegetable => 'yes', count => 10 }, ); my @a2 = ( { name => 'orange', fruit => 'yes', vegetable => 'no', count => 60, id =>123 }, { name => 'squash', fruit => 'no', vegetable => 'yes', count => 10, id => 222 }, ); my $count = 0; for my $first (@a1){ my $name = $first->{name}; my $second = $a2[$count]; for (keys %$second){ if (! exists $first->{$_}){ print "\@a2 has $_ for $name but \@a1 doesn't\n"; } } for my $k (keys %$first){ if (! exists $second->{$k}){ print "$k doesn't exist in \@a2 for $name\n"; next; } my $ne = 0; if ($first->{$k} =~ /^\d+$/){ if ($first->{$k} != $second->{$k}){ $ne = 1; } } else { if ($first->{$k} ne $second->{$k}){ $ne = 1; } } print "$k changed from $first->{$k} to $second->{$k} in $name\n" if $ne; } $count++; } } __END__ @a2 has id for orange but @a1 doesn't count changed from 50 to 60 in orange @a2 has id for squash but @a1 doesn't