in reply to Merging the seperated

Even though it sounds like homework (summer school?) ... here's a general solution for any number of arrays:
sub merge { my %h; for my $l (0..$#_) { $h{$_}[$l] = $_ for @{$_[$l]}; } map [ map { defined $_ ? $_ : '-' } @{$h{$_}}[0..$#_] ], sort { $a <=> $b } keys %h; } ### Example ### use strict; use Data::Dumper; my @h = merge [3,5,2,6], [7,3,6], [1,6,2,9], [0,3,4,1]; print Dumper \@h;
Your code could be cleaner, but algorithmically, you've got the right idea.
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print