<?xml version="1.0" encoding="windows-1252"?>
<node id="73480" title="Mixing up da Arrays (Golf)" created="2001-04-18 13:08:22" updated="2005-08-13 01:44:16">
<type id="115">
perlquestion</type>
<author id="3568">
ChOas</author>
<data>
<field name="doctext">
Hey People,&lt;BR&gt;
&lt;BR&gt;
As usual [leons] and I were coding a bit, and tried&lt;BR&gt; 
to find a way to mix n number of m lenght arrays &lt;BR&gt;
together, preserving the original order of the &lt;BR&gt;
original arrays&lt;BR&gt;
&lt;BR&gt;
I came up with this:&lt;BR&gt;
&lt;CODE&gt;
#!/usr/bin/perl -w

use strict;

sub Mix;

my @Row1=(1,3,5,7);
my @Row2=(2,4,6);
my @Row3=(9,9,9);
my @Row4=Mix(\@Row1,\@Row2,\@Row3);

print "@Row4\n";

sub Mix
{
 my @Result;
 while(1)
 {
  my $Old=@Result;
  push @Result,grep $_,shift @{$_} for @_;
  last if @Result==$Old;
 };
 @Result;
};
&lt;/CODE&gt;
&lt;I&gt;Output: 1 2 9 3 4 9 5 6 9 7&lt;/I&gt;&lt;BR&gt;&lt;BR&gt;
Anyway to do it quicker/more efficient/shorter ?&lt;BR&gt;
&lt;BR&gt;
&lt;BR&gt;
GreetZ!,&lt;BR&gt;&lt;UL&gt;ChOas&lt;/UL&gt;
&lt;BR&gt;
&lt;FONT SIZE="1"&gt;print "profeth still\n" if /bird|devil/;&lt;/FONT&gt;</field>
</data>
</node>
