for (0 .. $#new_data) { foreach my $old_data (@old_data) { $new_data[$_] ne $old_data && next; splice @new_data, $_, 1; } }