Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Merge 2 strings like a zip

by Anonymous Monk
on Jul 11, 2015 at 20:34 UTC ( [id://1134315]=note: print w/replies, xml ) Need Help??


in reply to Re: Merge 2 strings like a zip
in thread Merge 2 strings like a zip

In keeping with your philosophy, here's something completely different :)

#!/usr/bin/perl # http://perlmonks.org/?node_id=1133857 use warnings; use strict; print zip("ABCDEFGHIJ", "abcde"), "\n"; sub zip { my ($str1, $str2) = @_; my $gap = length($str1) - 1; my $len2 = length $str2; join '', grep defined, "$str1$str2" =~ /(.)(?=.{$gap}(.)|.{$len2})/g +s; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1134315]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found