in reply to Merging the seperated
Your code could be cleaner, but algorithmically, you've got the right idea.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;
MeowChow s aamecha.s a..a\u$&owag.print
|
|---|