| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | Quiq::AsciiTable - Analysiere ASCII-Tabelle | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | L<Quiq::Hash> | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | Ein Objekt der Klasse repräsentiert eine Tabelle, die in Form | ||||||||||||||||||||||||||||||||||||||||||
| 16 | eines ASCII-Texts gegeben ist. Diese Darstellung wird an den | ||||||||||||||||||||||||||||||||||||||||||
| 17 | Konstruktor übergeben und von diesem analysiert. Die Klasse stellt | ||||||||||||||||||||||||||||||||||||||||||
| 18 | Methoden zur Verfügung, um die Eigenschaften der Tabelle abzufragen. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | =head2 Aufbau einer ASCII-Tabelle | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | Eine ASCII-Tabelle hat den allgemeinen Aufbau: | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | Right Left Center | ||||||||||||||||||||||||||||||||||||||||||
| 25 | ----- ---- ------ | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 A A | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 21 AB AB | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 321 ABC ABC | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 4321 ABCD ABCD | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | Die Tabelle besteht aus einem Tabellen-Kopf und einem | ||||||||||||||||||||||||||||||||||||||||||
| 32 | Tabellen-Körper. Der Kopf enthält die Kolumnen-Titel und der | ||||||||||||||||||||||||||||||||||||||||||
| 33 | Körper die Kolumnen-Daten. Die beiden Bereiche werden durch eine | ||||||||||||||||||||||||||||||||||||||||||
| 34 | Trennzeile aus Bindestrichen (-) und Leerzeichen (SPACE) | ||||||||||||||||||||||||||||||||||||||||||
| 35 | getrennt. Außer der Trennung in Kopf und Körper definiert die | ||||||||||||||||||||||||||||||||||||||||||
| 36 | Trennzeile durch die Bindestriche die Anzahl, Lage und | ||||||||||||||||||||||||||||||||||||||||||
| 37 | Breite der einzelnen Kolumnen. | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | Obige Tabelle besitzt z.B. drei Kolumnen: Die erste Kolumne ist 5 | ||||||||||||||||||||||||||||||||||||||||||
| 40 | Zeichen breit und reicht von Zeichenposition 0 bis 4. Die zweite | ||||||||||||||||||||||||||||||||||||||||||
| 41 | Kolumne ist 4 Zeichen breit und reicht von Zeichenposition | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 bis 9. Die dritte Kolumne ist 6 Zeichen breit und reicht von | ||||||||||||||||||||||||||||||||||||||||||
| 43 | Zeichenpostion 11 bis 16. Die Positionsangaben sind zeilenbezogen | ||||||||||||||||||||||||||||||||||||||||||
| 44 | und 0-basiert. | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | Aus der Anordnung der Werte in einer Kolumne - I<sowohl im Kopf als | ||||||||||||||||||||||||||||||||||||||||||
| 47 | auch im Körper> - ergibt sich, ob die Kolumne links, rechts oder | ||||||||||||||||||||||||||||||||||||||||||
| 48 | zentriert ausgerichtet ist. Bei einer links ausgerichteten | ||||||||||||||||||||||||||||||||||||||||||
| 49 | Kolumne belegen I<alle> (nichtleeren) Werte die erste Zeichenpositon. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | Bei einer rechts ausgerichteten Kolumne belegen I<alle> (nichtleeren) | ||||||||||||||||||||||||||||||||||||||||||
| 51 | Werte die letzte Zeichenpositon. Bei einer zentrierten Kolumne | ||||||||||||||||||||||||||||||||||||||||||
| 52 | sind die Werte weder eindeutig links noch rechts ausgerichtet. | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | Der Tabellen-Kopf, also die Titel, können mehrzeilig sein: | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | Right Left | ||||||||||||||||||||||||||||||||||||||||||
| 57 | Aligned Aligned Centered | ||||||||||||||||||||||||||||||||||||||||||
| 58 | ------- ------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 A A | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 21 AB AB | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 321 ABC ABC | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 4321 ABCD ABCD | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | Die Titel sind optional, können also auch fehlen: | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | ----- ---- ------ | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 A A | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 21 AB AB | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 321 ABC ABC | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 4321 ABCD ABCD | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | Die Kolumnenwerte können ebenfalls mehrzeilig sein: | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | Right Left | ||||||||||||||||||||||||||||||||||||||||||
| 75 | Aligned Aligned Centered | ||||||||||||||||||||||||||||||||||||||||||
| 76 | ------- -------------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 This is A | ||||||||||||||||||||||||||||||||||||||||||
| 78 | the first row | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 Second row B | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 The third C | ||||||||||||||||||||||||||||||||||||||||||
| 83 | row | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | Bei einer Tabelle mit mehrzeiligen Kolumnenwerten werden die | ||||||||||||||||||||||||||||||||||||||||||
| 86 | Zeilen durch Trennzeilen getrennt, gleichgültig, ob die einzelne | ||||||||||||||||||||||||||||||||||||||||||
| 87 | Zeile einen mehrzeiligen Kolumnenwert enhält oder nicht (siehe | ||||||||||||||||||||||||||||||||||||||||||
| 88 | Zeile 2). Die Trennzeile kann eine einfache Leerzeile sein oder | ||||||||||||||||||||||||||||||||||||||||||
| 89 | Bindestriche enthalten wie die Trennzeile zwischen Tabellen-Kopf | ||||||||||||||||||||||||||||||||||||||||||
| 90 | und -Körper: | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | Right Left | ||||||||||||||||||||||||||||||||||||||||||
| 93 | Aligned Aligned Centered | ||||||||||||||||||||||||||||||||||||||||||
| 94 | ------- -------------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 This is A | ||||||||||||||||||||||||||||||||||||||||||
| 96 | the first line | ||||||||||||||||||||||||||||||||||||||||||
| 97 | ------- -------------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 Second line B | ||||||||||||||||||||||||||||||||||||||||||
| 99 | ------- -------------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 The third C | ||||||||||||||||||||||||||||||||||||||||||
| 101 | line | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ------- -------------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | Ferner gilt hinsichtlich der Formatierung: | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | Ist die Tabelle eingerückt, wird diese Einrückung automatisch | ||||||||||||||||||||||||||||||||||||||||||
| 111 | entfernt. Die Einrückung muss aus Leerzeichen bestehen. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | Leerzeien oberhalb und unterhalb der Tabelle werden entfernt. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | package Quiq::AsciiTable; | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | use base qw/Quiq::Hash/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | use Quiq::Unindent; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | =head2 Konstruktor | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | =head3 new() - Instantiiere Objekt | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | $tab = $class->new($str); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | =head4 Arguments | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | =item $str | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | Zeichenkette mit ASCII-Tabelle. | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | Tabellen-Objekt | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | Instantiiere ein Tabellen-Objekt und liefere eine Referenz auf | ||||||||||||||||||||||||||||||||||||||||||
| 163 | dieses Objekt zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=35 SCAR=35.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | my ($class,$str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | # Einrückung entfernen | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 7 | $str = Quiq::Unindent->trimNl($str); | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # Zeilen einlesen | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # * In Daten- und Trennzeilen differenzieren | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # * Separator-Zeile ermitteln | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # * Feststellen, ob es sich im eine Multiline-Tabelle handelt | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 7 | my @lines; # Zeile: [$type,$text] | |||||||||||||||||||||||||||||||||||||||||
| 181 | 7 | my $titles = 1; # Titelzeile(n) vorhanden | |||||||||||||||||||||||||||||||||||||||||
| 182 | 7 | my $sepLine; # Separator-Zeile unter Titel | |||||||||||||||||||||||||||||||||||||||||
| 183 | 7 | my $multiLine = -1; # Multizeilen-Tabelle, wenn > 0 | |||||||||||||||||||||||||||||||||||||||||
| 184 | 7 | my $tabLineLength; # Logische Breite einer ASCII-Tabellenzeile | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | for (split /\n/,$str) { | |||||||||||||||||||||||||||||||||||||||||
| 187 | 42 | ▶ | if (/^[- ]*$/) { # Bindestrich-Zeile, Whitespace-Zeile, Leerzeile | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 11 | ▶ | if (!@lines) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | $titles = 0; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | # Die erste Trennzeile definiert das Kolumnenlayout | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 11 | ▶ | if (!defined $sepLine) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | $sepLine = $_; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 6 | $tabLineLength = length $sepLine; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 11 | $multiLine++; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 11 | push @lines,[0,$_]; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | # Datenzeile | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 31 | push @lines,[1,$_]; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # Prüfe, ob die Eingabedaten eine Tabelle darstellen | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 7 | ▶ | if (!$sepLine || substr($sepLine,0,1) ne '-') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $sepLine or substr($sepLine, 0, 1) ne "-"
MC/DC50%1/2
not $sepLine or substr($sepLine, 0, 1) ne "-"
not $sepLine
substr($sepLine, 0, 1) ne "-"
Truth table66%2/3
not(A) or B
A= not $sepLineB= substr($sepLine, 0, 1) ne "-"
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | $class->throw( | |||||||||||||||||||||||||||||||||||||||||
| 211 | 'TABLE-00001: No table (no parting line)', | ||||||||||||||||||||||||||||||||||||||||||
| 212 | Input => $str, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | # Positionen und Kolumnenbreiten bestimmen. Diese Information | ||||||||||||||||||||||||||||||||||||||||||
| 217 | # wird aus der Separatorzeile gewonnen. | ||||||||||||||||||||||||||||||||||||||||||
| 218 | # $type==0: Zwischenraum, $type==1: Daten | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 6 | my @ranges; # [$type,$pos,$width] | |||||||||||||||||||||||||||||||||||||||||
| 221 | 6 | my $tableWidth = 0; # Anzahl der Kolumnen der Tabelle | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 6 | my $pos = 0; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | my @arr = split /( +)/,$sepLine; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 6 | ▶ | while (@arr) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 26 | my $str = shift @arr; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 26 | my $width = length $str; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 26 | ▶ | if (substr($str,0,1) eq '-') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | # Daten-Bereich | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 16 | push @ranges,[1,$pos,$width]; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 16 | $tableWidth++; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | # Kolumnentrenner-Bereich (Spaces) | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 10 | push @ranges,[0,$pos,$width]; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 26 | $pos += $width; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | # Titel- und Datenzeilen bestimmen | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | # Hilfsfunktion: Zeile mit Leerzeichen auffüllen | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 28 | ▶ | my $pad = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 28 | my ($text,$len) = @_; # Text, Länge | |||||||||||||||||||||||||||||||||||||||||
| 246 | 28 | return $text .= ' ' x ($len - length $text); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | # Hilfsfunktion: Daten aus Zeile extrahieren | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 80 | ▶ | my $extract = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 80 | my ($text,$r) = @_; # Text, Range | |||||||||||||||||||||||||||||||||||||||||
| 253 | 80 | return substr $text,$r->[1],$r->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 6 | my (@columns,@titles,@align,@rows); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | ▶ | while (@lines) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 39 | my $line = shift @lines; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 39 | ▶ | if ($line->[0]) { # Datenzeile | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 28 | my $lineText = $pad->($line->[1],$tabLineLength); | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 28 | my $i = 0; # Kolumnen-Index | |||||||||||||||||||||||||||||||||||||||||
| 263 | 28 | ▶ | for (my $j = 0; $j < @ranges; $j++) { # Range-Index | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 132 | my $r = $ranges[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 132 | ▶ | if ($r->[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 80 | my $str = $extract->($lineText,$r); | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | # Whitespace bereinigen | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 80 | my ($wsLeft,$wsRight); | |||||||||||||||||||||||||||||||||||||||||
| 271 | 80 | ▶ | if ($str =~ s/^ +//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 44 | $wsLeft = 1; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 80 | ▶ | if ($str =~ s/ +$//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 38 | $wsRight = 1; | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 80 | ▶ | if ($str eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | # Leere Zelle | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 10 | $wsLeft = $wsRight = 0; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | # Ausrichtung des Kolumnenwerts ermitteln | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 80 | ▶ | if ($wsLeft && $wsRight) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$wsLeft and $wsRight
MC/DC100%2/2
$wsLeft and $wsRight
$wsLeft
$wsRight
Truth table100%3/3
A and B
A= $wsLeftB= $wsRight
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 16 | $align[$i]{'c'}++; # centered ' x ' | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | elsif ($wsLeft) { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 18 | $align[$i]{'r'}++; # right ' x' | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | elsif ($wsRight) { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 22 | $align[$i]{'l'}++; # left 'x ' | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 24 | $align[$i]{'u'}++; # unknown 'x' | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | # Kolumnenwert speichern | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 80 | ▶ | if (defined $columns[$i] && $columns[$i] ne '' && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $columns[$i] and $columns[$i] ne "" and $str ne ""
defined $columns[$i] and $columns[$i] ne ""
MC/DC100%3/3
defined $columns[$i] and $columns[$i] ne "" and $str ne ""
defined $columns[$i]
$columns[$i] ne ""
$str ne ""
Truth table100%4/4
A and B and C
A= defined $columns[$i]B= $columns[$i] ne ""C= $str ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | $str ne '') { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 11 | $columns[$i] .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 80 | $columns[$i++] .= $str; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 28 | ▶ | if (!$multiLine && (!$titles || @titles)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $multiLine and !$titles || @titles
not $titles or @titles
MC/DC100%3/3
not $multiLine and !$titles || @titles
not $multiLine
not $titles
@titles
Truth table100%4/4
not(A) and not(B) or C
A= not $multiLineB= not $titlesC= @titles
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 10 | push @rows,[@columns]; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 10 | @columns = (); | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | elsif (@columns) { # Trennzeile nachdem Datenzeilen gelesen wurden | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 10 | ▶ | if ($titles && !@titles) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$titles and not @titles
MC/DC50%1/2
$titles and not @titles
$titles
not @titles
Truth table66%2/3
A and not(B)
A= $titlesB= not @titles
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 5 | @titles = @columns; | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 5 | push @rows,[@columns]; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 10 | @columns = (); | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 6 | ▶ | if (@columns) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | push @rows,[@columns]; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | # Kolumnen-Ausrichtung ermitteln | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 6 | ▶ | for (my $i = 0; $i < @align; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 16 | ▶ | if ($align[$i]{'c'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 5 | $align[$i] = 'c'; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | ▶ | elsif ($align[$i]{'l'} && $align[$i]{'r'}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$align[$i]{"l"} and $align[$i]{"r"}
MC/DC0%0/2
$align[$i]{"l"} and $align[$i]{"r"}
$align[$i]{"l"}
$align[$i]{"r"}
Truth table66%2/3
A and B
A= $align[$i]{"l"}B= $align[$i]{"r"}
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $align[$i] = 'c'; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | elsif ($align[$i]{'r'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 5 | $align[$i] = 'r'; | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 6 | $align[$i] = 'l'; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | return $class->SUPER::new( | |||||||||||||||||||||||||||||||||||||||||
| 343 | str => $str, | ||||||||||||||||||||||||||||||||||||||||||
| 344 | width => $tableWidth, | ||||||||||||||||||||||||||||||||||||||||||
| 345 | alignA => \@align, | ||||||||||||||||||||||||||||||||||||||||||
| 346 | rangeA => \@ranges, | ||||||||||||||||||||||||||||||||||||||||||
| 347 | multiLine => $multiLine, | ||||||||||||||||||||||||||||||||||||||||||
| 348 | titleA => \@titles, | ||||||||||||||||||||||||||||||||||||||||||
| 349 | rowA => \@rows, | ||||||||||||||||||||||||||||||||||||||||||
| 350 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | =head2 Eigenschaften | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | =head3 alignments() - Ausrichtung der Kolumnenwerte | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | @align | $alignA = $tab->alignments; | ||||||||||||||||||||||||||||||||||||||||||
| 362 | @align | $alignA = $tab->alignments($domain); | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | =head4 Arguments | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | =item $domain (Default: 'latex') | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | Legt die gelieferte Wertemenge fest. | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | =item 'latex' | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | Gelieferte Werte: 'l', 'r', 'c'. | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | =item 'html' | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | Gelieferte Werte: 'left', 'right', 'center'. | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | Liste der Kolumnenausrichtungen. Im Skalarkontext liefere eine | ||||||||||||||||||||||||||||||||||||||||||
| 389 | Referenz auf die Liste. | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | Liefere die Liste der Kolumnenausrichtungen der Domäne $domain. | ||||||||||||||||||||||||||||||||||||||||||
| 394 | Mögliche Ausrichtungen: | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | Zentriert (centered). | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | Rechtsbündig (right aligned). | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | Linksbündig (left aligned). | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | Tabelle: | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | Right Left Centered | ||||||||||||||||||||||||||||||||||||||||||
| 417 | Aligned Aligned Header | ||||||||||||||||||||||||||||||||||||||||||
| 418 | ------- ------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 A A | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 21 AB AB | ||||||||||||||||||||||||||||||||||||||||||
| 421 | 321 ABC ABC | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | Resultat: | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | @align = $tab->alignments; | ||||||||||||||||||||||||||||||||||||||||||
| 426 | # ('r','l','c') | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 6 | ▶ | sub alignments { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alignments: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 434 | 6 | ▶ | my $domain = shift // 'latex'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // "latex"
MC/DC0%0/1
shift() // "latex"
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 6 | my $alignA = $self->{'alignA'}; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 6 | ▶ | if ($domain eq 'html') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $alignA = [map {{l=>'left',r=>'right',c=>'center'}->{$_}} @$alignA]; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 6 | ▶ | return wantarray? @$alignA: $alignA; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | =head3 multiLine() - Tabelle ist MultiLine-Tabelle | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | $bool = $tab->multiLine; | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | Boolean | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | Liefere 1, wenn die Tabelle eine MultiLine-Tabelle ist, andernfalls 0. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | Tabelle: | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | Right Left Centered | ||||||||||||||||||||||||||||||||||||||||||
| 465 | Aligned Aligned Header | ||||||||||||||||||||||||||||||||||||||||||
| 466 | ------- ------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 Erste A | ||||||||||||||||||||||||||||||||||||||||||
| 468 | Zeile | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 2 Zweite B | ||||||||||||||||||||||||||||||||||||||||||
| 471 | Zeile | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 Dritte C | ||||||||||||||||||||||||||||||||||||||||||
| 474 | Zeile | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | Resultat: | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | $multiLine = $tab->multiLine; | ||||||||||||||||||||||||||||||||||||||||||
| 479 | # 1 | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | =head3 rows() - Liste der Zeilen | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | @rows | $rowA = $tab->rows; | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | Liste der Zeilen. Im Skalarkontext liefere eine Referenz auf die | ||||||||||||||||||||||||||||||||||||||||||
| 490 | Liste. | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | Tabelle: | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | Right Left Centered | ||||||||||||||||||||||||||||||||||||||||||
| 497 | Aligned Aligned Header | ||||||||||||||||||||||||||||||||||||||||||
| 498 | ------- ------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 1 A A | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 21 AB AB | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 321 ABC ABC | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | Resultat: | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | @rows = $tab->rows; | ||||||||||||||||||||||||||||||||||||||||||
| 506 | # (['1', 'A', 'A'], | ||||||||||||||||||||||||||||||||||||||||||
| 507 | # ['21', 'AB', 'AB'], | ||||||||||||||||||||||||||||||||||||||||||
| 508 | # ['321','ABC','ABC']) | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 6 | ▶ | sub rows { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rows: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 6 | my $rowA = $self->{'rowA'}; | |||||||||||||||||||||||||||||||||||||||||
| 517 | 6 | ▶ | return wantarray? @$rowA: $rowA; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | =head3 titles() - Liste der Kolumnentitel | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | @titles | $titleA = $tab->titles; | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | Liste der Kolumnentitel. Im Skalarkontext liefere eine Referenz | ||||||||||||||||||||||||||||||||||||||||||
| 531 | auf die Liste. | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | Tabelle: | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | Right Left Centered | ||||||||||||||||||||||||||||||||||||||||||
| 538 | Aligned Aligned Header | ||||||||||||||||||||||||||||||||||||||||||
| 539 | ------- ------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 A A | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 21 AB AB | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 321 ABC ABC | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | Resultat: | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | @titles = $tab->titles; | ||||||||||||||||||||||||||||||||||||||||||
| 547 | # ("Right\nAligned","Left\nAligned","Centered\nHeader") | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | 6 | ▶ | sub titles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
titles: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 555 | 6 | my $titleA = $self->{'titleA'}; | |||||||||||||||||||||||||||||||||||||||||
| 556 | 6 | ▶ | return wantarray? @$titleA: $titleA; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | =head3 width() - Anzahl der Kolumnen | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | $n = $tab->width; | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | Kolumnenanzahl (Integer > 0) | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | Liefere die Anzahl der Kolumnen der Tabelle. | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | Tabelle: | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | Right Left Centered | ||||||||||||||||||||||||||||||||||||||||||
| 580 | Aligned Aligned Header | ||||||||||||||||||||||||||||||||||||||||||
| 581 | ------- ------- -------- | ||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 A A | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 21 AB AB | ||||||||||||||||||||||||||||||||||||||||||
| 584 | 321 ABC ABC | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | Resultat: | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | $n = $tab->width; | ||||||||||||||||||||||||||||||||||||||||||
| 589 | # 3 | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | =head2 Formate | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | =head3 asText() - Liefere ASCII-Tabelle | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | $str = $class->asText; | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | ASCII-Tabelle (String) | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | Liefere die Tabelle als Zeichenkette, wie sie dem Konstruktor | ||||||||||||||||||||||||||||||||||||||||||
| 606 | übergeben wurde, jedoch ohne Einrückung. | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 3 | ▶ | sub asText { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
asText: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 3 | return shift->{'str'}; | |||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | 1.240 | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 633 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | # eof | ||||||||||||||||||||||||||||||||||||||||||