1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
$sth=$dbh->prepare("SELECT * FROM kunden WHERE kdnummer LIKE '$kdnummer'"); $sth->execute(); $Text::Table::Tiny::COLUMN_SEPARATOR = '|'; $Text::Table::Tiny::ROW_SEPARATOR = '-'; $Text::Table::Tiny::CORNER_MARKER = '+'; $Text::Table::Tiny::HEADER_ROW_SEPARATOR = '_'; $Text::Table::Tiny::HEADER_CORNER_MARKER = '|'; # Tabellentest $rows=[]; push @$rows, [qw(kdnummer kddatum kdfirma kdstrasse kdhausnummer kdplz kdort kdland kdansprechpartner kdtelefon kdfax kdemail)]; while(@row = $sth->fetchrow_array){ @row=map{decode("UTF-8", $_)}@row; push @$rows, [@row]; } print Text::Table::Tiny::table(rows => $rows, header_row => 1); print " \n"; print "$rows \n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+-----------------------------------------------------+
| E********** / Daten-Verwaltungs-Programm (EZ-DVP) |
+-----------------------------------------------------+
>> Rechnung erstellen <<
Rechnungskopf laden durch Eingabe der Kundennummer :100102
+----------+---------+---------+-----------+--------------+-------+-------+--------+-------------------+-----------+-------+---------+
| kdnummer | kddatum | kdfirma | kdstrasse | kdhausnummer | kdplz | kdort | kdland | kdansprechpartner | kdtelefon | kdfax | kdemail |
+----------+---------+---------+-----------+--------------+-------+-------+--------+-------------------+-----------+-------+---------+
+----------+---------+---------+-----------+--------------+-------+-------+--------+-------------------+-----------+-------+---------+
ARRAY(0x1985fd8)
Datensatzsuche beendet! [ENTER]
1 2 3 4 5 6
$rows=[]; push @$rows, [qw(kdnummer kddatum kdfirma kdstrasse kdhausnummer kdplz kdort kdland kdansprechpartner kdtelefon kdfax kdemail)]; while(@row = $sth->fetchrow_array){ @row=map{decode("UTF-8", $_)}@row; push @$rows, [@row]; }
my $kdnummer_aus_zeile_3 = $rows->[3][0];
1 2 3 4 5 6
my $kdnummer = "12345" for my $zeile (@$rows) { next unless $zeile->[0] eq $kdnummer; # print join('; ', @{$rows->[$zeile]}), "\n"; # FALSCH print join('; ', @$zeile), "\n"; # korrigiert }
1 2 3 4
for my $zeile = (@$rows) { next unless $zeile->[0] eq $kdnummer; print join('; ', @{$rows->[$zeile]}), "\n"; }
1
2
3
4
5
syntax error at ./EZ-DVP.pl line 2906, near "$zeile ="
Global symbol "$zeile" requires explicit package name at ./EZ-DVP.pl line 2907.
Global symbol "$zeile" requires explicit package name at ./EZ-DVP.pl line 2908.
syntax error at ./EZ-DVP.pl line 2909, near "}"
Execution of ./EZ-DVP.pl aborted due to compilation errors.
1
2
3
nhalt von array-row:
Inhalt von skalar-rows: ARRAY(0xd16110)
Inhalt von array-skalar-rows: ARRAY(0xd150a8) ARRAY(0xd158b8)
1 2
my ($REkdnummer, $REkddatum, $REkdfirma, $REkdstrasse, $REkdhausnummer, $REkdplz, $REkdort, $REkdland, $REkdansprechpartner, $REkdtelefon, $REkdfax, $REkdemail) = split(/ /,@row); print "$REkdnummer, $REkddatum, $REkdfirma, $REkdstrasse, $REkdhausnummer, $REkdplz, $REkdort, $REkdland, $REkdansprechpartner, $REkdtelefon, $REkdfax, $REkdemail \n";
split(/ /,@row);
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
if ($rows eq "") {goto Rechnungen;} my $REkdnummer = ""; my $REkddatum = ""; my $REkdfirma = ""; my $REkdstrasse = ""; my $REkdhausnummer = ""; my $REkdplz = ""; my $REkdort = ""; my $REkdland = ""; my $REkdansprechpartner = ""; my $REkdtelefon = ""; my $REkdfax = ""; my $REkdemail = ""; $REkdnummer = $rows->[1][0]; $REkddatum = $rows->[1][1]; $REkdfirma = $rows->[1][2]; $REkdstrasse = $rows->[1][3]; $REkdhausnummer = $rows->[1][4]; $REkdplz = $rows->[1][5]; $REkdort = $rows->[1][6]; $REkdland = $rows->[1][7]; $REkdansprechpartner = $rows->[1][8]; $REkdtelefon = $rows->[1][9]; $REkdfax = $rows->[1][10]; $REkdemail = $rows->[1][11]; print "$REkdnummer \n"; print "$REkddatum \n"; print "$REkdfirma \n"; print "$REkdstrasse \n"; print "$REkdhausnummer \n"; print "$REkdplz \n"; print "$REkdort \n"; print "$REkdland \n"; print "$REkdansprechpartner \n"; print "$REkdtelefon \n"; print "$REkdfax \n"; print "$REkdemail \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
+-----------------------------------------------------+
| E********** / Daten-Verwaltungs-Programm (EZ-DVP) |
+-----------------------------------------------------+
>> Rechnung erstellen <<
Rechnungskopf laden durch Eingabe der Kundennummer :100102
+----------+---------+---------+-----------+--------------+-------+-------+--------+-------------------+-----------+-------+---------+
| kdnummer | kddatum | kdfirma | kdstrasse | kdhausnummer | kdplz | kdort | kdland | kdansprechpartner | kdtelefon | kdfax | kdemail |
+----------+---------+---------+-----------+--------------+-------+-------+--------+-------------------+-----------+-------+---------+
+----------+---------+---------+-----------+--------------+-------+-------+--------+-------------------+-----------+-------+---------+
Use of uninitialized value $REkdnummer in concatenation (.) or string at ./EZ-DVP.pl line 2928.
Use of uninitialized value $REkddatum in concatenation (.) or string at ./EZ-DVP.pl line 2929.
Use of uninitialized value $REkdfirma in concatenation (.) or string at ./EZ-DVP.pl line 2930.
Use of uninitialized value $REkdstrasse in concatenation (.) or string at ./EZ-DVP.pl line 2931.
Use of uninitialized value $REkdhausnummer in concatenation (.) or string at ./EZ-DVP.pl line 2932.
Use of uninitialized value $REkdplz in concatenation (.) or string at ./EZ-DVP.pl line 2933.
Use of uninitialized value $REkdort in concatenation (.) or string at ./EZ-DVP.pl line 2934.
Use of uninitialized value $REkdland in concatenation (.) or string at ./EZ-DVP.pl line 2935.
Use of uninitialized value $REkdansprechpartner in concatenation (.) or string at ./EZ-DVP.pl line 2936.
Use of uninitialized value $REkdtelefon in concatenation (.) or string at ./EZ-DVP.pl line 2937.
Use of uninitialized value $REkdfax in concatenation (.) or string at ./EZ-DVP.pl line 2938.
Use of uninitialized value $REkdemail in concatenation (.) or string at ./EZ-DVP.pl line 2939.
Datensatzsuche beendet! [ENTER]
2012-09-30T17:05:36 ?Wie kann ich prüfen, ob $rows leer, bzw. undefiniert ist.
1 2 3 4 5 6 7 8
my $kdnummer = '21365123'; for my $zeile (@$rows) { my $kn = $zeile->[0]; if ($kn eq $kdnummer) { print "$_\n" for @$zeile; # die Elemente von @$zeile sind Deine Werte } }
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
my $REkdnummer = $rows->[1][0]; my $REkddatum = $rows->[1][1]; my $REkdfirma = $rows->[1][2]; my $REkdstrasse = $rows->[1][3]; my $REkdhausnummer = $rows->[1][4]; my $REkdplz = $rows->[1][5]; my $REkdort = $rows->[1][6]; my $REkdland = $rows->[1][7]; my $REkdansprechpartner = $rows->[1][8]; my $REkdtelefon = $rows->[1][9]; my $REkdfax = $rows->[1][10]; my $REkdemail = $rows->[1][11]; if (not defined $REkdnummer) {$REkdnummer = "-";} if (not defined $REkddatum) {$REkddatum = "-";} if (not defined $REkdfirma) {$REkdfirma = "-";} if (not defined $REkdstrasse) {$REkdstrasse = "-";} if (not defined $REkdhausnummer) {$REkdhausnummer = "-";} if (not defined $REkdplz) {$REkdplz = "-";} if (not defined $REkdort) {$REkdort = "-";} if (not defined $REkdland) {$REkdland = "-";} if (not defined $REkdansprechpartner) {$REkdansprechpartner = "-";} if (not defined $REkdtelefon) {$REkdtelefon = "-";} if (not defined $REkdfax) {$REkdfax = "-";} if (not defined $REkdemail) {$REkdemail = "-";} if ($REkdnummer eq "-") {goto Rechnungen;} print "$REkdnummer \n"; print "$REkddatum \n"; print "$REkdfirma \n"; print "$REkdstrasse \n"; print "$REkdhausnummer \n"; print "$REkdplz \n"; print "$REkdort \n"; print "$REkdland \n"; print "$REkdansprechpartner \n"; print "$REkdtelefon \n"; print "$REkdfax \n"; print "$REkdemail \n";