perlquestion
ChOas
Hey People,<BR>
<BR>
As usual [leons] and I were coding a bit, and tried<BR>
to find a way to mix n number of m lenght arrays <BR>
together, preserving the original order of the <BR>
original arrays<BR>
<BR>
I came up with this:<BR>
<CODE>
#!/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;
};
</CODE>
<I>Output: 1 2 9 3 4 9 5 6 9 7</I><BR><BR>
Anyway to do it quicker/more efficient/shorter ?<BR>
<BR>
<BR>
GreetZ!,<BR><UL>ChOas</UL>
<BR>
<FONT SIZE="1">print "profeth still\n" if /bird|devil/;</FONT>