Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Merge 2 strings like a zip

by Anonymous Monk
on Jul 09, 2015 at 14:41 UTC ( [id://1133970]=note: print w/replies, xml ) Need Help??


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

zip() without /r and unzip()

#!/usr/bin/perl # http://perlmonks.org/?node_id=1133857 use warnings; use strict; print zip("ABCDEFGHIJ", "abcde"), "\n"; print "@{[ unzip('AaBbCcDdEeFGHIJ', 5) ]}\n"; sub zip # if no /r { my ($str1, $str2) = @_; $str1 =~ s/.\K/ substr $str2, 0, 1, ''/ges; $str1 } sub unzip { my ($input, $length2) = @_; return join('', unpack "(ax)$length2 a*", $input), join '', unpack "(xa)$length2", $input; }

Replies are listed 'Best First'.
Re^4: Merge 2 strings like a zip
by tel2 (Pilgrim) on Jul 10, 2015 at 00:18 UTC
    Nice work, Anonymous Monk!

    Thanks again.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-23 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found