Thread Wiedermal Probleme mit Arrays (6 answers)
Opened by Arasiel at 2003-12-11 11:10

Crian
 2003-12-11 13:47
#75499 #75499
User since
2003-08-04
5873 Artikel
ModeratorIn
[Homepage]
user image
So z.B.:

Code: (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl
use strict;
use warnings;

use Data::Dumper;

my @array1 = (
"Tabelle_X where Bedingung1 = '...' and Bedingung2 = '...'",
"Tabelle_X where Bedingung1 = '...' and Bedingung2 = '...'",
"Tabelle_X where Bedingung1 = '...'",
"Tabelle_Y where Bedingung1 = '...' and Bedingung2 = '...'",
"Tabelle_Y where Bedingung1 = '...'",
"Tabelle_Z where Bedingung1 = '...' and Bedingung2 = '...'",
);

my @array2 = (
"Tabelle_X : Feld1 Feld2 Feld3",
"Tabelle_Y : Feld1 Feld2",
"Tabelle_Z : Feld1 Feld2 Feld3",
);

print Dumper \@array1;
print Dumper \@array2;

my @array3;

my $i1 = 0;
my $i2 = 0;

while ($i1 < scalar @array1 and $i2 < scalar @array2) {
my ($tab1, $where) = split / /, $array1[$i1], 2;
my ($tab2, $fields) = split / : /, $array2[$i2], 2;

#print "i1=$i1, i2=$i2, tab1=$tab2, tab2=$tab2, where=$where, fields=$fields\n";

if ($tab1 eq $tab2) {
push @array3, "select $fields from $tab1 $where";
++$i1;
}
else {
++$i2;
}
}

print Dumper \@array3;


Ausgabe:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$VAR1 = [
'Tabelle_X where Bedingung1 = \'...\' and Bedingung2 = \'...\'',
'Tabelle_X where Bedingung1 = \'...\' and Bedingung2 = \'...\'',
'Tabelle_X where Bedingung1 = \'...\'',
'Tabelle_Y where Bedingung1 = \'...\' and Bedingung2 = \'...\'',
'Tabelle_Y where Bedingung1 = \'...\'',
'Tabelle_Z where Bedingung1 = \'...\' and Bedingung2 = \'...\''
];
$VAR1 = [
'Tabelle_X : Feld1 Feld2 Feld3',
'Tabelle_Y : Feld1 Feld2',
'Tabelle_Z : Feld1 Feld2 Feld3'
];
$VAR1 = [
'select Feld1 Feld2 Feld3 from Tabelle_X where Bedingung1 = \'...\' and Bedingung2 = \'...\'',
'select Feld1 Feld2 Feld3 from Tabelle_X where Bedingung1 = \'...\' and Bedingung2 = \'...\'',
'select Feld1 Feld2 Feld3 from Tabelle_X where Bedingung1 = \'...\'',
'select Feld1 Feld2 from Tabelle_Y where Bedingung1 = \'...\' and Bedingung2 = \'...\'',
'select Feld1 Feld2 from Tabelle_Y where Bedingung1 = \'...\'',
'select Feld1 Feld2 Feld3 from Tabelle_Z where Bedingung1 = \'...\' and Bedingung2 = \'...\''
];
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite

View full thread Wiedermal Probleme mit Arrays