<?xml version="1.0" encoding="windows-1252"?>
<node id="67973" title="(Golf) Strings-to-Array" created="2001-03-28 21:13:09" updated="2005-08-13 03:20:02">
<type id="1588">
obfuscated</type>
<author id="1936">
japhy</author>
<data>
<field name="doctext">
Here's the goal:  make a function that takes any number of equal-length strings, and returns an array of strings, where each string is the concatenation of the Nth character in each string.

&lt;p&gt;

Sample input:  &lt;tt&gt;qw( jeff john mary )&lt;/tt&gt;&lt;br&gt;
Sample output:  &lt;tt&gt;qw( jjm eoa fhr fny )&lt;/tt&gt;

&lt;p&gt;

Here are my attempts:

&lt;code&gt;
# 51 chars
sub s2a{@_=@_;reverse+map{join"",map+chop,@_}1..length$_[0]}

# 51 chars
sub s2a{@_=@_;map{join"",map+s/(.)//s&amp;&amp;$1,@_}1..length$_[0]}

# 48 chars
sub s2a{map{join"",map+s/(.)//s&amp;&amp;$1,@_=@_}1..length$_[0]}

# 47 chars
sub s2a{map{join"",map{s/(.)//s;$1}@_=@_}1..length$_[0]}

# 45 chars
sub s2a{map{join"",map{s/.//s;$&amp;}@_=@_}1..length$_[0]}
&lt;/code&gt;

&lt;br&gt;&lt;br&gt;
&lt;tt&gt;&lt;font color="#0000ff"&gt;japhy&lt;/font&gt;&lt;/tt&gt; -- 
&lt;a href="/index.pl?node=japhy&amp;lastnode_id=1072"&gt;Perl and Regex Hacker&lt;/a&gt;</field>
</data>
</node>
