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
#!/usr/bin/perl use strict; use warnings; use DBI; use Fcntl ':flock'; use FindBin '$Bin'; use Text::Table::Tiny; use $Text::Table::Tiny::COLUMN_SEPARATOR = '|'; use $Text::Table::Tiny::ROW_SEPARATOR = '-'; use $Text::Table::Tiny::CORNER_MARKER = '+'; use $Text::Table::Tiny::HEADER_ROW_SEPARATOR = '='; use $Text::Table::Tiny::HEADER_CORNER_MARKER = 'O'; #Tabellentest.pl my $rows = [ # header row ['Name', 'Rank', 'Serial'], # rows ['alice', 'pvt', '123456'], ['bob', 'cpl', '98765321'], ['carol', 'brig gen', '8745'], ];
Quotesyntax error at ./Tabellentest.pl line 10, near "use $Text::Table::Tiny::COLUMN_SEPARATOR "
Execution of ./Tabellentest.pl aborted due to compilation errors.
1 2 3 4 5
# nicht so # use $Text::Table::Tiny::COLUMN_SEPARATOR = '|'; # einfach so $Text::Table::Tiny::COLUMN_SEPARATOR = '|';
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
#!/usr/bin/perl use strict; use warnings; use DBI; use Fcntl ':flock'; use FindBin '$Bin'; use Text::Table::Tiny; $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 = 'O'; #Tabellentest.pl my $rows = [ # header row ['Name', 'Rank', 'Serial'], # rows ['alice', 'pvt', '123456'], ['bob', 'cpl', '98765321'], ['carol', 'brig gen', '8745'], ];
1
2
# separate rows puts lines between rows, header_row says that the first row is headers
print Text::Table::Tiny::table(rows => $rows, separate_rows => 1, header_row => 1);
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
$sth=$dbh->prepare("SELECT * FROM kunden WHERE kdnummer LIKE '$kdnummer'"); $sth->execute(); #while(my @row = $sth->fetchrow_array){ # print join('; ',@row)."\n"; # } $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.pl my $rows = [ # header row ['kdnummer', 'kddatum', 'kdfirma', 'kdstrasse', 'kdhausnummer', 'kdplz', 'kdort', 'kdland', 'kdansprechpartner', 'kdtelefon', 'kdfax', 'kdemail'], # rows ['alice', 'pvt', '123456'], ['bob', 'cpl', '98765321'], ['carol', 'brig gen', '8745'], ]; print Text::Table::Tiny::table(rows => $rows, header_row => 1); print " \n"; print " \n"; print "Datensatzsuche beendet! [ENTER] \n";
'$kdnummer' , '$kddatum', '$kdfirma', '$kdstrasse', '$kdhausnummer', '$kdplz', '$kdort', '$kdland', '$kdansprechpartner', '$kdtelefon', '$kdfax', '$kdemail'
1 2 3
my $rows=[]; push @$rows, [qw(kdnummer kddatum kdfirma kdstrasse kdhausnummer kdplz kdort kdland kdansprechpartner kdtelefon kdfax kdemail)]; push @$rows, ['wert','wert','wert','wert','wert','wert','wert','wert','wert','wert','wert','wert'];
1 2 3 4
push @$rows, [qw(kdnummer kddatum kdfirma kdstrasse kdhausnummer kdplz kdort kdland kdansprechpartner kdtelefon kdfax kdemail)]; while(@row = $sth->fetchrow_array){ push @$rows, [$kdnummer , $kddatum, $kdfirma, $kdstrasse, $kdhausnummer, $kdplz, $kdort, $kdland, $kdansprechpartner, $kdtelefon, $kdfax, $kdemail]; }
1 2 3
$t="Das hier ist ein Testtext"; @array=split(/ /,$t); foreach (@array){print "$_\n";}
1
2
3
4
5
6
7
8
9
Bitte gesuchte Kundennummer eingeben :100102
+----------+----------+---------+-----------+--------------+-------+--------+--------+-------------------+-----------+--------+----------------+
| kdnummer | kddatum | kdfirma | kdstrasse | kdhausnummer | kdplz | kdort | kdland | kdansprechpartner | kdtelefon | kdfax | kdemail |
+----------+----------+---------+-----------+--------------+-------+--------+--------+-------------------+-----------+--------+----------------+
| 100102 | 20120917 | ffgh | fghfh | fghfgh | fhfgh | fghfgh | fghf | fghfhfh | 4646 | 645656 | 45ghjghjg21ghj |
+----------+----------+---------+-----------+--------------+-------+--------+--------+-------------------+-----------+--------+----------------+
Datensatzsuche beendet! [ENTER]
1
2
3
4
5
6
7
8
9
10
11
Bitte gesuchte Kundennummer eingeben :100100
+----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+
| kdnummer | kddatum | kdfirma | kdstrasse | kdhausnummer | kdplz | kdort | kdland | kdansprechpartner | kdtelefon | kdfax | kdemail |
+----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+
| 100100 | 20120917 | MaxTech | Musterstrasse | 11 | 79576 | Weil am Rhein | D | Herr Müller | 123456 | 123456 | service@maxtech.de |
| 100100 | 20120917 | Testshop | Testweg | 13 | 79618 | Rheinfelden | D | Frau Tester | 123456 | 1234567 | test@tester.de |
| 100100 | 20120917 | kjhkjh | lkjlkj | 45 | 78987 | ölkölk | D | Herr Lölle | 321 | 654 | 654@mnbmn.de |
+----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+
Datensatzsuche beendet! [ENTER]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
$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){ push @$rows, [@row]; } print Text::Table::Tiny::table(rows => $rows, header_row => 1); print " \n"; print " \n"; print "Datensatzsuche beendet! [ENTER] \n"; $sth->finish(); $dbh->disconnect();
1 2 3 4 5 6
my $dbh = DBI->connect($dsn, $user, $pass, { mysql_enable_utf8 => 1 }); ... push @$rows, [@row]; ... binmode STDOUT, ":encoding(utf-8)"; print Text::Table::Tiny::table(rows => $rows, header_row => 1);
1 2 3 4 5 6 7 8 9 10 11
Bitte gesuchte Kundennummer eingeben :100100 +----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+ | kdnummer | kddatum | kdfirma | kdstrasse | kdhausnummer | kdplz | kdort | kdland | kdansprechpartner | kdtelefon | kdfax | kdemail | +----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+ | 100100 | 20120917 | MaxTech | Musterstrasse | 11 | 79576 | Weil am Rhein | D | Herr Müller | 123456 | 123456 | service@maxtech.de | | 100100 | 20120917 | Testshop | Testweg | 13 | 79618 | Rheinfelden | D | Frau Tester | 123456 | 1234567 | test@tester.de | | 100100 | 20120917 | kjhkjh | lkjlkj | 45 | 78987 | ölkölk | D | Herr Lölle | 321 | 654 | 654@mnbmn.de | +----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+ Datensatzsuche beendet! [ENTER]
1 2 3 4 5 6 7 8 9
$rows=[]; push @$rows, [qw(kdnummer kddatum kdfirma kdstrasse kdhausnummer kdplz kdort kdland kdansprechpartner kdtelefon kdfax kdemail)]; while(@row = $sth->fetchrow_array){ push @$rows, [@row]; } binmode STDOUT, ":encoding(utf-8)"; print Text::Table::Tiny::table(rows => $rows, header_row => 1); print " \n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use strict; use warnings; use Encode; binmode STDOUT, ":encoding(UTF-8)"; # ... my $rows=[]; push @$rows, [qw(kdnummer kddatum kdfirma kdstrasse kdhausnummer kdplz kdort kdland kdansprechpartner kdtelefon kdfax kdemail)]; while(my @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";
binmode STDOUT, ":encoding(UTF-8)";
1
2
3
4
5
6
7
+----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+
| kdnummer | kddatum | kdfirma | kdstrasse | kdhausnummer | kdplz | kdort | kdland | kdansprechpartner | kdtelefon | kdfax | kdemail |
+----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+
| 100100 | 20120917 | MaxTech | Musterstrasse | 11 | 79576 | Weil am Rhein | D | Herr Müller | 123456 | 123456 | service@maxtech.de |
| 100100 | 20120917 | Testshop | Testweg | 13 | 79618 | Rheinfelden | D | Frau Tester | 123456 | 1234567 | test@tester.de |
| 100100 | 20120917 | kjhkjh | lkjlkj | 45 | 78987 | ölkölk | D | Herr Lölle | 321 | 654 | 654@mnbmn.de |
+----------+----------+----------+---------------+--------------+-------+---------------+--------+-------------------+-----------+---------+--------------------+
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
+-----------------------------------------------------+
| E********** / Daten-Verwaltungs-Programm (EZ-DVP) |
+-----------------------------------------------------+
>> Hauptmenü <<
+-----------------------------------------------------+
| [1] Kunden anlegen... |
| |
| [2] Kunden suchen... |
| |
| [3] Kunden editieren... |
| |
| [4] Kurzgeschichte anlegen... |
| |
| [5] Kurzgeschichte suchen... |
| |
| [6] Kurzgeschichte editieren... |
| |
| [7] Buchungsstatus abfragen... |
| |
| [8] Statistik aufrufen... |
| |
| [9] Datenbank sichern... |
| |
| [10] Hilfe anzeigen... |
|-----------------------------------------------------|
| [0] Programm beenden... |
+-----------------------------------------------------+
Bitte Aufgabe wählen [x]:
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
################################################################### HauptMenu: ################################################################### system("clear"); print "+-----------------------------------------------------+ \n"; print "| E********** / Daten-Verwaltungs-Programm (EZ-DVP) | \n"; print "+-----------------------------------------------------+ \n"; print " \n"; print ">> Hauptmenü << \n"; print " \n"; print "+-----------------------------------------------------+ \n"; print "| [1] Kunden anlegen... | \n"; print "| | \n"; print "| [2] Kunden suchen... | \n"; print "| | \n"; print "| [3] Kunden editieren... | \n"; print "| | \n"; print "| [4] Kurzgeschichte anlegen... | \n"; print "| | \n"; print "| [5] Kurzgeschichte suchen... | \n"; print "| | \n"; print "| [6] Kurzgeschichte editieren... | \n"; print "| | \n"; print "| [7] Buchungsstatus abfragen... | \n"; print "| | \n"; print "| [8] Statistik aufrufen... | \n"; print "| | \n"; print "| [9] Datenbank sichern... | \n"; print "| | \n"; print "| [10] Hilfe anzeigen... | \n"; print "|-----------------------------------------------------| \n"; print "| [0] Programm beenden... | \n"; print "+-----------------------------------------------------+ \n"; print " \n"; print "Bitte Aufgabe wählen [x]:"; my $decider; $decider = <STDIN>; chop($decider); if ($decider eq "1") {goto KundenAnlegen;} if ($decider eq "2") {goto KundenSuchen;} if ($decider eq "3") {goto KundenEditieren;} if ($decider eq "4") {goto KurzgeschichteAnlegen;} if ($decider eq "5") {goto KurzgeschichteSuchen;} if ($decider eq "6") {goto KurzgeschichteEditieren;} if ($decider eq "7") {goto BuchungsstatusAbfragen;} if ($decider eq "8") {goto StatistikAufrufen;} if ($decider eq "9") {goto DatenbankSichern;} if ($decider eq "10") {goto HilfeAnzeigen;} if ($decider eq "0") {goto ProgrammBeenden;} goto HauptMenu;
1 2 3 4
print CGI->header('text/html'); print <<"ENDE"; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">