in reply to delete multiple occurrences

Or using grep:

my $q = '' ; my $i = 0 ; @anew = grep { my $p = $q ; $q = $b[$i++] eq 'z' ; !($p && $q) } @a +;
(having checked that the arrays @a and @b are the same length, at least).