Leser: 27
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
tmp_container[0]->[0]->[0] = CIS
tmp_container[0]->[0]->[1] = P1
tmp_container[0]->[0]->[2] = [b]A1[/b]
tmp_container[0]->[1]->[0] = off
tmp_container[0]->[2]->[0] = AAA
tmp_container[0]->[2]->[1] = xxx
tmp_container[0]->[3]->[0] = on
------------------------------------
tmp_container[1]->[0]->[0] = AAA
tmp_container[1]->[0]->[1] = yyy
tmp_container[1]->[1]->[0] = on
------------------------------------
tmp_container[2]->[0]->[0] = AAA
tmp_container[2]->[0]->[1] = zzz
tmp_container[2]->[1]->[0] = on
------------------------------------
tmp_container[3]->[0]->[0] = BBB
tmp_container[3]->[0]->[1] = xxx
tmp_container[3]->[1]->[0] = on
------------------------------------
tmp_container[4]->[0]->[0] = BBB
tmp_container[4]->[0]->[1] = yyy
tmp_container[4]->[1]->[0] = on
------------------------------------
tmp_container[5]->[0]->[0] = BBB
tmp_container[5]->[0]->[1] = zzz
tmp_container[5]->[1]->[0] = on
------------------------------------
tmp_container[6]->[0]->[0] = CIS
tmp_container[6]->[0]->[1] = P1
tmp_container[6]->[0]->[2] = [b]A2[/b]
tmp_container[6]->[1]->[0] = off
tmp_container[6]->[2]->[0] = AAA
tmp_container[6]->[2]->[1] = xxx
tmp_container[6]->[3]->[0] = on
------------------------------------
tmp_container[7]->[0]->[0] = AAA
tmp_container[7]->[0]->[1] = yyy
tmp_container[7]->[1]->[0] = on
------------------------------------
tmp_container[8]->[0]->[0] = AAA
tmp_container[8]->[0]->[1] = zzz
tmp_container[8]->[1]->[0] = on
------------------------------------
tmp_container[9]->[0]->[0] = BBB
tmp_container[9]->[0]->[1] = xxx
tmp_container[9]->[1]->[0] = on
------------------------------------
...
...
...
1 2 3 4 5 6 7 8 9 10
for(my $r=0;$r<@tmp_container;$r++){ for(my $s=0;$s<@{$tmp_container[$r]};$s++){ for(my $t=0;$t<@{$tmp_container[$r]->[$s]};$t++) { if(@{$tmp_container[$r-1]} > @{$tmp_container[$r]}){ unshift(@{$tmp_container[$r]}, $tmp_container->[$r-1]->[$s]->[$t]); } } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14
my @add; for my $arr (@tmp_container) { if(@{$arr->[0]}>2) { my @val1=@{$arr->[0]}; my @val2=@{$arr->[1]}; @add=[\@val1,\@val2]; } else { unshift(@{$arr},@add); } }
@add=(\@val1,\@val2);
1 2 3 4 5 6 7 8 9 10 11
my @add; for my $arr (@tmp_container) { if( @{$arr->[0]} > 2 ) { my @val1 = @{$arr->[0]}; my @val2 = @{$arr->[1]}; @add=(\@val1,\@val2); } else { unshift( @{$arr}, [ @{$add[0]} ], [ @{$add[1]} ]); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
for(my $j=0;$j<@{$PA_ARRAY_FKT[$indexFunction]};$j++) { for(my $k=0;$k<@{$PA_ARRAY_FKT[$indexFunction]->[$indexParameter]};$k) { $CONTAINER[$indexFunction]->[$indexParameter]->[$INDEX_ARRAY_PARAM[$indexFunction]->[$indexParameter]] = $PA_ARRAY_FKT[$indexFunction]->[$indexParameter]->[$INDEX_ARRAY_PARAM[$indexFunction]->[$indexParameter]]; #--- ist der aktuelle Parameter der letzte --------------------------------------------------------------- if(($indexParameter+1) >= @{$PA_ARRAY_FKT[$indexFunction]} ) { #--- Ist der aktuelle ParameterWert der letzte --------------------------------------------------------------- if(($INDEX_ARRAY_PARAM[$indexFunction]->[$indexParameter]+1) >= @{$PA_ARRAY_FKT[$indexFunction]->[$j]} ) { $tmp_container[$a]->[$b]->[$c] = $PA_ARRAY_FKT[$indexFunction]->[$indexParameter]->[$INDEX_ARRAY_PARAM[$indexFunction]->[$indexParameter]]; ... ... ... #Dann soll das Array aufgefüllt werden. #Im nächsten Durchlauf kommen neue Werte hinzu #und hier muss ggf. auch aufgefüllt werden
2010-12-14T12:47:24 sebi85Bei beiden Lösungen verliere ich aber eine Dimension.
1 2 3
print "\n1: ".$add[0]."\n"; print "\n2: ".$add[0]->[0]."\n"; print "\n3: ".$add[0]->[0]->[0]."\n";
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @tmp_container=(); $tmp_container[0]->[0]->[0] = 'CIS'; $tmp_container[0]->[0]->[1] = 'P1'; $tmp_container[0]->[0]->[2] = 'A1'; $tmp_container[0]->[1]->[0] = 'off'; $tmp_container[0]->[2]->[0] = 'AAA'; $tmp_container[0]->[2]->[1] = 'xxx'; $tmp_container[0]->[3]->[0] = 'on'; #------------------------------------ $tmp_container[1]->[0]->[0] = 'AAA'; $tmp_container[1]->[0]->[1] = 'yyy'; $tmp_container[1]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[2]->[0]->[0] = 'AAA'; $tmp_container[2]->[0]->[1] = 'zzz'; $tmp_container[2]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[3]->[0]->[0] = 'BBB'; $tmp_container[3]->[0]->[1] = 'xxx'; $tmp_container[3]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[4]->[0]->[0] = 'BBB'; $tmp_container[4]->[0]->[1] = 'yyy'; $tmp_container[4]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[5]->[0]->[0] = 'BBB'; $tmp_container[5]->[0]->[1] = 'zzz'; $tmp_container[5]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[6]->[0]->[0] = 'CIS'; $tmp_container[6]->[0]->[1] = 'P1'; $tmp_container[6]->[0]->[2] = 'A2'; $tmp_container[6]->[1]->[0] = 'off'; $tmp_container[6]->[2]->[0] = 'AAA'; $tmp_container[6]->[2]->[1] = 'xxx'; $tmp_container[6]->[3]->[0] = 'on'; #------------------------------------ $tmp_container[7]->[0]->[0] = 'AAA'; $tmp_container[7]->[0]->[1] = 'yyy'; $tmp_container[7]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[8]->[0]->[0] = 'AAA'; $tmp_container[8]->[0]->[1] = 'zzz'; $tmp_container[8]->[1]->[0] = 'on'; #------------------------------------ $tmp_container[9]->[0]->[0] = 'BBB'; $tmp_container[9]->[0]->[1] = 'xxx'; $tmp_container[9]->[1]->[0] = 'on'; #------------------------------------ #print Dumper(\@tmp_container); my @add; for my $arr (@tmp_container) { if(@{$arr->[0]}>2) { @add=($arr->[0],$arr->[1]); } else { my @add1=@{$add[0]}; my @add2=@{$add[1]}; unshift(@{$arr},\@add1,\@add2); } } #print Dumper(\@tmp_container); print "\n1: ".$tmp_container[0]."\n"; print "\n2: ".$tmp_container[0]->[0]."\n"; print "\n3: ".$tmp_container[0]->[0]->[0]."\n"; print "\n1: ".$tmp_container[1]."\n"; print "\n2: ".$tmp_container[1]->[0]."\n"; print "\n3: ".$tmp_container[1]->[0]->[0]."\n"; print "\n1: ".$tmp_container[2]."\n"; print "\n2: ".$tmp_container[2]->[0]."\n"; print "\n3: ".$tmp_container[2]->[0]->[0]."\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
my @val; if(...){ for(my $x=0;$x<(@PA_ARRAY_FKT-2);$x++) { $val[$x] = @{$arr->[$x]}; print "\n1: val[$x] = ".@{$arr->[$x]}."\n"; @add = (\@val); } else { for(my $x=0;$x<@add;$x++) { unshift( @{$arr}, [ @{$add[0]} ], [ @{$add[1]} ]); } }
2011-01-10T09:55:36 sebi85Ich möchte folgendes variabel haben:
In diesem Fall werden immer zwei Werte aufgefüllt, es sollen aber 1-unendlich aufgefüllt werden.
2011-01-10T09:55:36 sebi85Code (perl): (dl )for(my $x=0;$x<(@PA_ARRAY_FKT-2);$x++)
1 2 3 4 5 6 7 8 9 10
for my $arr (@tmp_container) { for() { for() { zum nächsten $arr } } }
1 2 3 4 5 6 7
COUNTER: for my $counter ( @values ) { ELEM: for my $elem ( @array ) { next COUNTER; } }
1 2 3 4 5 6 7 8 9 10
OUTSIDE: for my $x ( 1 ..3 ) { INSIDE: for my $y ( 'a' .. 'c' ) { print "$x : $y\n"; next OUTSIDE if $y eq 'b'; } }