in reply to Merge 2 strings like a zip

Thanks everyone for your contributions to my education.

I now realise my original code could have been simplified (and sped up) like this:

sub zip { my ($str1, $str2) = @_; my $zip; for (0 .. length($str2)-1) { $zip .= substr($str1, $_, 1) . substr($str2, $_, 1) } $zip .= substr($str1, length($str2)); return $zip; }

Of course that only meets my original spec's (i.e. 2nd string must be the shortest) but it seems to be pretty fast (though I guess the concatenation would slow it down if my data was much longer).