$_ .= shift @d for @z; # Elegant, but destroys @d. my $i; $_ .= $d[$i++] for @z; # Less elegant, no destruction.