Thread spliten von mehrdimensionalem array
(21 answers)
Opened by anou at 2010-10-28 19:59
nehmen wir mal folgendes an:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 my @array1=( [qw(small_motif_b 789 799)], [qw(small_motif_a 811 821)], [qw(small_motif_i 822 832)], [qw(tall_motif_a 833 880)], [qw(small_motif_a 881 891)], [qw(small_motif_b 892 902)], [qw(small_motif_a 903 913)], [qw(tall_motif_b 914 961)], [qw(small_motif_a 962 972)], [qw(tall_motif_c 973 1020)], ); my @array2=( [qw(NC_010109.1 NTRFinder . . . ID=NTR-a1;Parent=NTR-a;Name=motif_small_b)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a2;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a3;Parent=NTR-a;Name=motif_small_i)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a4;Parent=NTR-a;Name=tall_motif_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a5;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a6;Parent=NTR-a;Name=motif_small_b)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a7;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a8;Parent=NTR-a;Name=tall_motif_b)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a9;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a10;Parent=NTR-a;Name=tall_motif_c)], ); Und die Einträge aus den Arrays in "@array1" sollen an der ditten Stelle der Arrays in das "@array2", wobei die Positionen miteinander Korrespondieren. Code (perl): (dl
)
1 2 3 4 for my $pos (0..$#array2) { splice(@{$array2[$pos]},2,0,@{$array1[$pos]}); } |