| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | Quiq::Perl - Erweiterte und abgesicherte Perl-Operationen | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | L<Quiq::Object> | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | Die Klasse implementiert grundlegende Perl-Operationen, die | ||||||||||||||||||||||||||||||||||||||||||
| 16 | Erweiterungen darstellen und/oder durch Exception-Behandlung | ||||||||||||||||||||||||||||||||||||||||||
| 17 | abgesichert sind. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | package Quiq::Perl; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 271 | ▶ | use base qw/Quiq::Object/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 271 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 271 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 270 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 270 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 270 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 270 | ▶ | use Quiq::Object; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 270 | ▶ | use Cwd (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 270 | ▶ | use Quiq::Array; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 270 | ▶ | use Quiq::Perl; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 270 | ▶ | use Quiq::Option; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 270 | ▶ | use Quiq::FileHandle; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 270 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head2 I/O | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =head3 autoFlush() - Aktiviere/Deaktiviere Pufferung auf Dateihandle | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | $this->autoFlush($fh); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | $this->autoFlush($fh,$bool); | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | Schalte Pufferung auf Dateihandle ein oder aus. | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | Der Aufruf ist äquivalent zu | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | $oldFh = select $fh; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | $| = $bool; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | select $oldFh; | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | =head4 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | perldoc -f select | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | Quiq::Perl->autoFlush(*STDOUT); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub autoFlush { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autoFlush: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $fh = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | my $bool = @_? shift: 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $oldFh = CORE::select $fh; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $ | = $bool; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | CORE::select $oldFh; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | =head3 binmode() - Aktiviere Binärmodus oder setze Layer | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | $class->binmode($fh); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | $class->binmode($fh,$layer); | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | Schalte Filehandle $fh in Binärmodus oder setze Layer $layer. | ||||||||||||||||||||||||||||||||||||||||||
| 100 | Die Methode ist eine Überdeckung der Perl-Funktion binmode und prüft | ||||||||||||||||||||||||||||||||||||||||||
| 101 | deren Returnwert. Im Fehlerfall wirft die Methode eine Exception. | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | =head4 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | perldoc -f binmode | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | Quiq::Perl->binmode(*STDOUT,':encoding(utf-8)'); | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 16 | ▶ | sub binmode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binmode: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 16 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 16 | my $fh = shift; | |||||||||||||||||||||||||||||||||||||||||
| 118 | # @_: $layer | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 16 | ▶ | my $r = @_? CORE::binmode($fh,$_[0]): CORE::binmode($fh); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 16 | ▶ | if (!defined $r) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $class->throw( | |||||||||||||||||||||||||||||||||||||||||
| 123 | 'FH-00012: binmode fehlgeschlagen', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | Errstr => $!, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 16 | return; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | =head3 print() - Schreibe auf Dateihandle | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | Quiq::Perl->print($fh,@data); | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | Schreibe Daten @data auf Dateihandle $fh. Die Methode ist eine | ||||||||||||||||||||||||||||||||||||||||||
| 142 | Überdeckung der Perl-Funktion print und prüft deren Returnwert. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | Im Fehlerfall wirft die Methode eine Exception. | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | =head4 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | perldoc -f print | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | Quiq::Perl->print($fh,"Hello world\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 23 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 23 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 23 | my $fh = shift; | |||||||||||||||||||||||||||||||||||||||||
| 160 | # @_: @data | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | # Wir unterdrücken Warnungen auf STDERR, die z.B. auftreten, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # wenn die Handle nicht geöffnet ist. Solche Fehler generieren | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # hier sowieso eine Exception. | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 270 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 23 | ▶ | unless (CORE::print $fh @_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $class->throw( | |||||||||||||||||||||||||||||||||||||||||
| 169 | 'PERL-00002: print fehlgeschlagen', | ||||||||||||||||||||||||||||||||||||||||||
| 170 | Errstr => $!, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =head3 use() - Lade Klasse per use | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | $class->use($class,$sloppy); | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | Lade Klasse $class per use. Im Fehlerfall wirft die Methdoe eine Exception. | ||||||||||||||||||||||||||||||||||||||||||
| 188 | Ist $sloppy wahr, wird keine Exception geworfen, sondern ein boolscher | ||||||||||||||||||||||||||||||||||||||||||
| 189 | Wert: 1 für erfolgreiche Ausführung, 0 für fehlgeschlagen. Die globale | ||||||||||||||||||||||||||||||||||||||||||
| 190 | Variable $@ gibt den Grund an. | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | =head4 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | L<loadClass|"loadClass() - Lade Klasse, falls nicht existent">() | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub use { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my ($class,$useClass,$sloppy) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | eval "CORE::use $useClass ()"; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($sloppy) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $@ =~ s/ at .*//s; # unnütze/störende Information abschneiden | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $class->throw( | |||||||||||||||||||||||||||||||||||||||||
| 210 | 'PERL-00001: use fehlgeschlagen', | ||||||||||||||||||||||||||||||||||||||||||
| 211 | Class => $useClass, | ||||||||||||||||||||||||||||||||||||||||||
| 212 | Error => $@, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | =head2 Sonstige Operationen | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | =head3 perlDoFile() - Überdeckung für do() | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | @arr|$val = Quiq::Perl->perlDoFile($file); | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | Überdeckung für die Perl-Funktion do() in der Variante do($file). Die | ||||||||||||||||||||||||||||||||||||||||||
| 232 | Funktion liefert den Wert des letzten ausgewerteten Ausdrucks bei | ||||||||||||||||||||||||||||||||||||||||||
| 233 | Ausführung der Datei $file. Im Fehlerfall wirft die Funktion | ||||||||||||||||||||||||||||||||||||||||||
| 234 | eine Exception. | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | Genaue Funktionsbeschreibung siehe Perl-Dokumentation. | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | Laden einer Konfigurationsdatei: | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | %cfg = Quiq::Perl->perlDoFile($file); | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | Inhalt Konfigurationsdatei: | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | use strict; | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | host => 'localhost', | ||||||||||||||||||||||||||||||||||||||||||
| 249 | datenbank => 'entw1', | ||||||||||||||||||||||||||||||||||||||||||
| 250 | benutzer => ['sys','system'] | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | ▶ | sub perlDoFile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perlDoFile: called CC=5 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | my ($class,$file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 3 | my @arr = CORE::do($file); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | Quiq::Object->throw( | |||||||||||||||||||||||||||||||||||||||||
| 262 | 'PERL-00001: do() could not parse file', | ||||||||||||||||||||||||||||||||||||||||||
| 263 | File => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 264 | Cwd => Cwd::getcwd, | ||||||||||||||||||||||||||||||||||||||||||
| 265 | InternalError => $@, | ||||||||||||||||||||||||||||||||||||||||||
| 266 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | ▶ | elsif (@arr == 1 && !defined $arr[0]) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
@arr == 1 and not defined $arr[0]
MC/DC0%0/2
@arr == 1 and not defined $arr[0]
@arr == 1
not defined $arr[0]
Truth table33%1/3
A and not(B)
A= @arr == 1B= not defined $arr[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | Quiq::Object->throw( | |||||||||||||||||||||||||||||||||||||||||
| 270 | 'PERL-00002: do() could not load file', | ||||||||||||||||||||||||||||||||||||||||||
| 271 | File => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 272 | Cwd => Cwd::getcwd, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | Error => $!, | ||||||||||||||||||||||||||||||||||||||||||
| 274 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | ▶ | return wantarray? @arr: $arr[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | =head2 Sigil | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | =head3 sigilToType() - Wandele Sigil in Datentyp-Bezeichner | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | $type = $this->sigilToType($sigil); | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | Wandele $sigil ('$', '@' oder '%') in Datentyp-Bezeichner ('SCALAR', | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 'ARRAY' oder 'HASH') und liefere diesen zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 190 | ▶ | sub sigilToType { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sigilToType: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 190 | my ($this,$sigil) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 190 | ▶ | if ($sigil eq '$') { return 'SCALAR' } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 145 | elsif ($sigil eq '@') { return 'ARRAY' } | |||||||||||||||||||||||||||||||||||||||||
| 304 | 25 | elsif ($sigil eq '%') { return 'HASH' } | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | $this->throw( | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | 'PERL-00001: Ungültiger Sigil', | |||||||||||||||||||||||||||||||||||||||||
| 308 | Sigil => $sigil, | ||||||||||||||||||||||||||||||||||||||||||
| 309 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | =head2 Symboltabellen | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | =head3 stash() - Referenz auf Symboltabelle eines Package | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | $refH = $this->stash($package); | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | Liefere eine Referenz auf den "Symbol Table Hash" (Stash) des | ||||||||||||||||||||||||||||||||||||||||||
| 325 | Package $package. Der Hash enthält für jede globale Variable und | ||||||||||||||||||||||||||||||||||||||||||
| 326 | jedes Unterpackage einen Eintrag. Existiert der Stash nicht (und | ||||||||||||||||||||||||||||||||||||||||||
| 327 | damit auch nicht das Package), liefere undef. | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 1101 | ▶ | sub stash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stash: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 1101 | my ($this,$package) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | # o main:: verweist unter Key 'main::' auf sich selbst | ||||||||||||||||||||||||||||||||||||||||||
| 337 | # o $stash->{$key} ist ein Tyeglob. Im Falle eines Verweises auf | ||||||||||||||||||||||||||||||||||||||||||
| 338 | # einen Unter-Stash findet sich der Unter-Stash auf dem Hash-Slot. | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # Daher als Returnwert \%{$stash}, nicht $stash! | ||||||||||||||||||||||||||||||||||||||||||
| 340 | # o Wir zerlegen den Package-Namen in seine Bestandteile und | ||||||||||||||||||||||||||||||||||||||||||
| 341 | # folgen den Stash-Verweisen | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 1101 | my $stash = \%main::; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 1101 | for my $key (split /::/,$package) { | |||||||||||||||||||||||||||||||||||||||||
| 345 | 2291 | $key .= '::'; | |||||||||||||||||||||||||||||||||||||||||
| 346 | 2291 | ▶ | if (!exists $stash->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 2289 | $stash = $stash->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 1099 | return \%{$stash}; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | =head2 Packages/Klassen | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | =head3 packages() - Liste der existierenden Packages | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | @arr|$arr = $this->packages; | ||||||||||||||||||||||||||||||||||||||||||
| 364 | @arr|$arr = $this->packages($package); | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | Liefere die Liste der existierenden Packages, die im Stash | ||||||||||||||||||||||||||||||||||||||||||
| 369 | des Package $package und darunter enthalten sind, einschließlich | ||||||||||||||||||||||||||||||||||||||||||
| 370 | Package $package selbst. Im Skalarkontext liefere eine Referenz | ||||||||||||||||||||||||||||||||||||||||||
| 371 | auf die Liste. Wird die Methode ohne Argument aufgerufen | ||||||||||||||||||||||||||||||||||||||||||
| 372 | wird Package 'main' angenommen. | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | B<Anmerkung> | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | Packages entstehen zur Laufzeit. Die Liste der Packages wird | ||||||||||||||||||||||||||||||||||||||||||
| 377 | nicht gecacht, sondern mit jedem Aufruf neu ermittelt. | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | Liste aller Packages, die das Programm aktuell geladen hat: | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | @arr = Quiq::Perl->packages; | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | Liste in sortierter Form | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | @arr = Quiq::Perl->packages->sort; | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | Liste, eingeschränkt auf Packages, deren Name einen Regex erfüllt: | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | @arr = Quiq::Perl->packages->select(qr/patch\d+/); | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | Liste aller Packages unterhalb und einschließlich Package X: | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | @arr = Quiq::Perl->packages('X'); | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 1098 | ▶ | sub packages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
packages: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 1098 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 1098 | ▶ | my $package = shift || 'main'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 'main'
MC/DC100%1/1
shift() || 'main'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 1098 | my $stash = $this->stash($package); | |||||||||||||||||||||||||||||||||||||||||
| 418 | 1098 | ▶ | if (!$stash) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | # Wenn Stash nicht existiert, liefere leere Liste bzw. undef | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 1097 | push my(@arr),$package; | |||||||||||||||||||||||||||||||||||||||||
| 424 | 1097 | for (keys %$stash) { | |||||||||||||||||||||||||||||||||||||||||
| 425 | 27435 | ▶ | if (/::$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 1096 | s/::$//; # :: am Ende entfernen | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 1096 | my $subPackage; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 1096 | ▶ | if ($package eq 'main') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | # Der Stash main:: enthält zwei Einträge, die wir ignorieren: | ||||||||||||||||||||||||||||||||||||||||||
| 431 | # 1) die Referenz auf sich selbst | ||||||||||||||||||||||||||||||||||||||||||
| 432 | # 2) einen Eintrag "<none>", der kein gültiger Paketname ist | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 277 | ▶ | next if $_ eq 'main' || $_ eq '<none>'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ eq "main" or $_ eq "<none>"
MC/DC50%1/2
$_ eq "main" or $_ eq "<none>"
$_ eq "main"
$_ eq "<none>"
Truth table66%2/3
A or B
A= $_ eq "main"B= $_ eq "<none>"
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 274 | $subPackage = $_; # wir wollen main:: am Anfang nicht | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 819 | $subPackage = "$package\::$_"; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 1093 | push @arr,$this->packages($subPackage); | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 1097 | ▶ | return wantarray? @arr: Quiq::Array->new(\@arr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | =head3 createClass() - Erzeuge Klasse | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | $class->createClass($newClass,@baseClasses); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | Erzeuge Klasse $newClass, falls sie noch nicht existiert, und | ||||||||||||||||||||||||||||||||||||||||||
| 459 | definiere die Klassen @baseClasses als deren Basisklassen. Die | ||||||||||||||||||||||||||||||||||||||||||
| 460 | Methode liefert keinen Wert zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | Die Basisklassen werden per "use base" geladen. | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 20 | ▶ | sub createClass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createClass: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 20 | my ($class,$newClass,@baseClasses) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 20 | ▶ | if (!defined *{"$newClass\::"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 19 | my $code = "package $newClass"; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 19 | ▶ | if (@baseClasses) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 18 | $code .= "; use base qw/@baseClasses/"; | |||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 19 | ▶ | eval $code; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 19 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $class->throw( | |||||||||||||||||||||||||||||||||||||||||
| 481 | 'PERL-00003: Klasse erzeugen fehlgeschlagen', | ||||||||||||||||||||||||||||||||||||||||||
| 482 | Code => $code, | ||||||||||||||||||||||||||||||||||||||||||
| 483 | Error => $@, | ||||||||||||||||||||||||||||||||||||||||||
| 484 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | =head3 classExists() - Prüfe Existenz von Klasse/Package | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | $bool = $class->classExists($class); | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =head4 Alias | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | packageExists() | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | Prüfe, ob die Perl-Klasse bzw. das Package $class in-memory | ||||||||||||||||||||||||||||||||||||||||||
| 506 | existiert, also von Perl bereits geladen wurde. Liefere I<wahr>, | ||||||||||||||||||||||||||||||||||||||||||
| 507 | wenn Klasse existiert, andernfalls I<falsch>. | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | Quiq::Perl->classExists('Quiq::Object'); | ||||||||||||||||||||||||||||||||||||||||||
| 512 | ==> | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 8 | ▶ | sub classExists { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
classExists: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 8 | my ($class,$testClass) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 521 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | 8 | ▶ | return defined *{"$testClass\::"}? 1: 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | { | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 270 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | 270 | *packageExists = \&classExists; | |||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | =head3 loadClass() - Lade Klasse, falls nicht existent | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | $class->loadClass($class); | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | Lade Klasse $class. Im Unterschied zu Methode L<use|"use() - Lade Klasse per use">() wird die | ||||||||||||||||||||||||||||||||||||||||||
| 541 | Moduldatei nur zu laden versucht, wenn es den Namensraum (Package) | ||||||||||||||||||||||||||||||||||||||||||
| 542 | der Klasse noch nicht gibt. | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | Quiq::Perl->loadClass('My::Application'); | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 2 | ▶ | sub loadClass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadClass: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 2 | my ($class,$useClass) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 2 | ▶ | if (!$class->classExists($useClass)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $class->use($useClass); | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | =head3 baseClasses() - Liefere Liste aller Basisklassen (einschl. UNIVERSAL) | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | @arr | $arr = $this->baseClasses($class); | ||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | Liefere die Liste der *aller* Basisklassen der Klasse $class, | ||||||||||||||||||||||||||||||||||||||||||
| 573 | einschließlich UNIVERSAL und deren Basisklassen. | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | Gegeben folgende Vererbungshierarchie: | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | Pkg6 Pkg7 | ||||||||||||||||||||||||||||||||||||||||||
| 580 | \ / | ||||||||||||||||||||||||||||||||||||||||||
| 581 | UNIVERSAL | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | Pkg1 | ||||||||||||||||||||||||||||||||||||||||||
| 584 | | | ||||||||||||||||||||||||||||||||||||||||||
| 585 | Pkg2 | ||||||||||||||||||||||||||||||||||||||||||
| 586 | / \ | ||||||||||||||||||||||||||||||||||||||||||
| 587 | Pkg3 Pkg4 | ||||||||||||||||||||||||||||||||||||||||||
| 588 | \ / | ||||||||||||||||||||||||||||||||||||||||||
| 589 | Pkg5 | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | Der Aufruf Quiq::Perl->baseClasses('Pkg5') liefert ein Array | ||||||||||||||||||||||||||||||||||||||||||
| 592 | mit den Elementen | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | Pkg3 Pkg2 Pkg1 Pkg4 UNIVERSAL Pkg6 Pkg7 | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | Die Klassen Pkg2 und Pkg1 werden nicht wiederholt. | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | 4 | ▶ | sub baseClasses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
baseClasses: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 4 | my ($this,$class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 4 | my (@arr,%seen); | |||||||||||||||||||||||||||||||||||||||||
| 606 | 4 | for ($this->baseClassesISA($class),'UNIVERSAL', | |||||||||||||||||||||||||||||||||||||||||
| 607 | $this->baseClassesISA('UNIVERSAL')) { | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 20 | ▶ | push @arr,$_ if !$seen{$_}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | 4 | ▶ | return wantarray? @arr: Quiq::Array->new(\@arr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | =head3 baseClassesISA() - Liefere Liste der ISA-Basisklassen | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | @arr | $arr = $this->baseClassesISA($class); | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | Liefere die Liste der Basisklassen der Klasse $class. | ||||||||||||||||||||||||||||||||||||||||||
| 625 | Jede Basisklasse kommt in der Liste genau einmal vor. | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | Gegeben folgende Vererbungshierarchie: | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | Pkg1 | ||||||||||||||||||||||||||||||||||||||||||
| 632 | | | ||||||||||||||||||||||||||||||||||||||||||
| 633 | Pkg2 | ||||||||||||||||||||||||||||||||||||||||||
| 634 | / \ | ||||||||||||||||||||||||||||||||||||||||||
| 635 | Pkg3 Pkg4 | ||||||||||||||||||||||||||||||||||||||||||
| 636 | \ / | ||||||||||||||||||||||||||||||||||||||||||
| 637 | Pkg5 | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | Der Aufruf Quiq::Perl->baseClassesISA('Pkg5') liefert ein Array | ||||||||||||||||||||||||||||||||||||||||||
| 640 | mit den Elementen | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | Pkg3 Pkg2 Pkg1 Pkg4 | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | Die Klassen Pkg2 und Pkg1 werden nicht wiederholt. | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | 28 | ▶ | sub baseClassesISA { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
baseClassesISA: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 28 | my ($this,$class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | 28 | my (@arr,%seen); | |||||||||||||||||||||||||||||||||||||||||
| 654 | 28 | for (Quiq::Perl->hierarchyISA($class)) { | |||||||||||||||||||||||||||||||||||||||||
| 655 | 80 | ▶ | push @arr,$_ if !$seen{$_}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | 28 | ▶ | return wantarray? @arr: Quiq::Array->new(\@arr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | =head3 hierarchyISA() - Liefere ISA-Hierarchie | ||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | @arr | $arr = $this->hierarchyISA($class); | ||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | Liefere die ISA-Hierarchie der Klasse $class. Kommt eine Basisklasse | ||||||||||||||||||||||||||||||||||||||||||
| 672 | in der Hierarchie mehrfach vor, erscheint sie mehrfach in der Liste. | ||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | Gegeben folgende Vererbungshierarchie: | ||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||
| 678 | Pkg1 | ||||||||||||||||||||||||||||||||||||||||||
| 679 | | | ||||||||||||||||||||||||||||||||||||||||||
| 680 | Pkg2 | ||||||||||||||||||||||||||||||||||||||||||
| 681 | / \\ | ||||||||||||||||||||||||||||||||||||||||||
| 682 | Pkg3 Pkg4 | ||||||||||||||||||||||||||||||||||||||||||
| 683 | \ / | ||||||||||||||||||||||||||||||||||||||||||
| 684 | Pkg5 | ||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | Der Aufruf Quiq::Perl->hierarchyISA('Pkg5') liefert ein Array | ||||||||||||||||||||||||||||||||||||||||||
| 687 | mit den Elementen | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | Pkg3 Pkg2 Pkg1 Pkg4 Pkg2 Pkg1 | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | Die Basisklassen Pkg2 und Pkg1 erscheinen zweimal. | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 120 | ▶ | sub hierarchyISA { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hierarchyISA: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 120 | my ($this,$class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | 120 | my @arr; | |||||||||||||||||||||||||||||||||||||||||
| 701 | 120 | ▶ | if (my $ref = $this->getVar($class,'@','ISA')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 702 | 80 | for my $base (@$ref) { | |||||||||||||||||||||||||||||||||||||||||
| 703 | 89 | push @arr,$base,$this->hierarchyISA($base); | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | 120 | ▶ | return wantarray? @arr: Quiq::Array->new(\@arr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | =head3 subClasses() - Liefere Liste aller Subklassen | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | @arr | $arr = $this->subClasses($class); | ||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | Liefere die Liste der Subklassen der Klasse $class. | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | Gegeben folgende Vererbungshierarchie: | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | Pkg1 | ||||||||||||||||||||||||||||||||||||||||||
| 727 | | | ||||||||||||||||||||||||||||||||||||||||||
| 728 | Pkg2 | ||||||||||||||||||||||||||||||||||||||||||
| 729 | / \ | ||||||||||||||||||||||||||||||||||||||||||
| 730 | Pkg3 Pkg4 | ||||||||||||||||||||||||||||||||||||||||||
| 731 | \ / | ||||||||||||||||||||||||||||||||||||||||||
| 732 | Pkg5 | ||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | Der Aufruf Quiq::Perl->subClasses('Pkg1') liefert ein Array | ||||||||||||||||||||||||||||||||||||||||||
| 735 | mit den Elementen: | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | Pkg2 Pkg3 Pkg4 Pkg5 | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | Die Reihenfolge der Elemente ist nicht definiert. | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | Liste in sortierter Form | ||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | @arr = Quiq::Perl->subClasses('Pkg1')->sort; | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | Liste, eingeschränkt auf Klassen, deren Name einen Regex erfüllt: | ||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | @arr = Quiq::Perl->subClasses('Pkg1')->select(qr/[45]/); | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | ▶ | sub subClasses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subClasses: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 762 | 2 | my ($this,$class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | 2 | my (@arr,%seen); | |||||||||||||||||||||||||||||||||||||||||
| 765 | 2 | for my $pkg ($this->packages) { | |||||||||||||||||||||||||||||||||||||||||
| 766 | 732 | ▶ | if (!$seen{$pkg}++ && $pkg ne $class && $pkg->isa($class)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not $seen{$pkg}++ and $pkg ne $class and $pkg->isa($class)
not $seen{$pkg}++ and $pkg ne $class
MC/DC66%2/3
not $seen{$pkg}++ and $pkg ne $class and $pkg->isa($class)
not $seen{$pkg}++
$pkg ne $class
$pkg->isa($class)
Truth table75%3/4
not(A) and B and C
A= not $seen{$pkg}++B= $pkg ne $classC= $pkg->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | 5 | push @arr,$pkg; | |||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | 2 | ▶ | return wantarray? @arr: Quiq::Array->bless(\@arr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | =head3 nextMethod() - Finde nächste Methoden-Instanz | ||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | ($nextClass,$nextMeth) = $this->nextMethod($class,$name,$startClass); | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||
| 784 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | 3 | ▶ | sub nextMethod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nextMethod: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 787 | 3 | my ($this,$class,$name,$startClass) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | 3 | my ($search,$nextClass,$nextMeth); | |||||||||||||||||||||||||||||||||||||||||
| 790 | 3 | for my $package ($class,$this->baseClasses($class)) { | |||||||||||||||||||||||||||||||||||||||||
| 791 | 14 | ▶ | if ($search) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | 8 | ▶ | if (my $sub = $this->getSubroutine($package,$name)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | 2 | ▶ | return wantarray? ($package,$sub): $sub; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||
| 796 | elsif ($package eq $startClass) { | ||||||||||||||||||||||||||||||||||||||||||
| 797 | 3 | $search = 1; | |||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||
| 806 | =head3 classNameToPath() - Übersetze Klassenname in Klassenpfad | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||
| 810 | $classPath = $class->classNameToPath($className); | ||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | Übersetze den Klassennamen $className in den entsprechenden | ||||||||||||||||||||||||||||||||||||||||||
| 815 | Klassenpfad (ohne Dateiendung) und liefere diesen zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 'A::B::C' => 'A/B/C' | ||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | 1 | ▶ | sub classNameToPath { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
classNameToPath: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 1 | my ($class,$str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 827 | 1 | $str =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | =head3 classPathToName() - Übersetze Klassenpfad in Klassenname | ||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | $className = $class->classPathToName($classPath); | ||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||
| 839 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | Übersetze Klassenpfad $classPath (ist eine Endung vorhanden, wird | ||||||||||||||||||||||||||||||||||||||||||
| 842 | sie entfernt) in den entsprechenden Klassennamen und liefere | ||||||||||||||||||||||||||||||||||||||||||
| 843 | diesen zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||
| 847 | 'A/B/C' ==> 'A::B::C' | ||||||||||||||||||||||||||||||||||||||||||
| 848 | 'A/B/C.pm' ==> 'A::B::C' | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | 2 | ▶ | sub classPathToName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
classPathToName: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 855 | 2 | my ($class,$str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | 2 | $str =~ s/\.(.*)$//; | |||||||||||||||||||||||||||||||||||||||||
| 858 | 2 | $str =~ s|/|::|g; | |||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | =head2 Typeglobs | ||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||
| 867 | =head3 createAlias() - Setze Typeglob-Eintrag | ||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||
| 869 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | $this->createAlias($package,$sym=>$ref); | ||||||||||||||||||||||||||||||||||||||||||
| 872 | $this->createAlias($sym=>$ref); | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||
| 876 | Weise dem Typeglob-Eintrag $sym in der Symboltabelle des Package | ||||||||||||||||||||||||||||||||||||||||||
| 877 | $package die Referenz $ref zu. Die Methode liefert keinen Wert | ||||||||||||||||||||||||||||||||||||||||||
| 878 | zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||
| 880 | Der Aufruf ist äquivalent zu: | ||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||
| 883 | *{"$package\::$sym"} = $ref; | ||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | Ist $package nicht angegeben wird das Package des Aufrufers | ||||||||||||||||||||||||||||||||||||||||||
| 886 | (d.h. das Package, aus dem heraus der Aufruf erfolgt) genommen. | ||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | Alias für Subroutine aus anderer Klasse: | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | Quiq::Perl->createAlias('MyClass',mySub=>\&MyClass1::mySub1); | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||
| 900 | Eintrag einer Closure in die Symboltabelle: | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | Quiq::Perl->createAlias(__PACKAGE__,mySub=>sub { <code> }); | ||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||
| 904 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||
| 910 | 3 | ▶ | sub createAlias { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createAlias: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | 3 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 912 | 3 | ▶ | my $package = @_ == 3? shift: caller; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 3 | my $sym = shift; | |||||||||||||||||||||||||||||||||||||||||
| 914 | 3 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 917 | 3 | *{"$package\::$sym"} = $ref; | |||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | =head3 createHash() - Erzeuge Package-globalen Hash | ||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | $ref = $this->createHash($package,$sym); | ||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | Erzeuge einen globalen Hash in Package $package und liefere eine Referenz | ||||||||||||||||||||||||||||||||||||||||||
| 933 | diesen zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | Erzeuge in $class den Hash %H: | ||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | $ref = $this->createHash($class,'H'); | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | die Referenz kann geblesst werden: | ||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||
| 949 | bless $ref,'Quiq::Hash'; | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | 2 | ▶ | sub createHash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createHash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | 2 | my ($this,$package,$sym) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 961 | 2 | *{"$package\::$sym"} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 2 | return *{"$package\::$sym"}{HASH}; | |||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | =head3 getHash() - Liefere Referenz auf Package-Hash | ||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | $ref = $this->getHash($package,$name); | ||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | $ref = Quiq::Perl->getHash($package,'H'); | ||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||
| 980 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||
| 982 | 1 | ▶ | sub getHash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getHash: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 983 | 1 | my ($this,$package,$sym) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||
| 985 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 986 | 1 | my $ref = *{"$package\::$sym"}{HASH}; | |||||||||||||||||||||||||||||||||||||||||
| 987 | 1 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | $this->throw( | |||||||||||||||||||||||||||||||||||||||||
| 989 | 'PERL-00001: Hash existiert nicht', | ||||||||||||||||||||||||||||||||||||||||||
| 990 | Error => $@, | ||||||||||||||||||||||||||||||||||||||||||
| 991 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||
| 994 | 1 | return $ref; | |||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||
| 997 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||
| 999 | =head3 setHash() - Setze Package-Hash auf Wert | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||
| 1001 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||
| 1003 | $ref = $this->setHash($package,$name,$ref); | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||
| 1007 | Setze Package-Hash mit dem Namen $name auf den von $ref | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | referenzierten Wert, also auf %$ref und liefere eine Referenz | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | auf die Variable zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | Die Methode kopiert den Wert, sie erzeugt keinen Alias! | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||
| 1013 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||
| 1015 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | Setze Paket-Hash 'h' auf den Wert %hash: | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||
| 1021 | $ref = Quiq::Perl->setHash($package,'h',\%hash); | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||
| 1027 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||
| 1029 | 2 | ▶ | sub setHash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setHash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 2 | my ($this,$package,$sym,$ref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1033 | 2 | %{"$package\::$sym"} = %$ref; | |||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | 2 | return *{"$package\::$sym"}{HASH}; | |||||||||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | =head3 createArray() - Erzeuge Package-globales Array | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | $ref = $this->createArray($package,$sym); | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||
| 1046 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | Erzeuge ein globales Array in Package $package und liefere eine | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | Referenz dieses zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||
| 1051 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | Erzeuge in $class das Array @A: | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | $ref = Quiq::Perl->createArray($class,'A'); | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||
| 1061 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | die Referenz kann geblesst werden: | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | bless $ref,'Quiq::Array'; | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||
| 1067 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||
| 1069 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||
| 1071 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||
| 1073 | 2 | ▶ | sub createArray { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
createArray: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1074 | 2 | my ($this,$package,$sym) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||
| 1076 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1077 | 2 | *{"$package\::$sym"} = []; | |||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||
| 1079 | 2 | return *{"$package\::$sym"}{ARRAY}; | |||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||
| 1082 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||
| 1084 | =head3 getArray() - Liefere Referenz auf Package-Array | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||
| 1086 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||
| 1088 | $ref = $this->getArray($package,$name); | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||
| 1090 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||
| 1092 | $ref = Quiq::Perl->getArray($package,'A'); | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||
| 1094 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||
| 1096 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||
| 1098 | 1 | ▶ | sub getArray { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getArray: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1099 | 1 | my ($this,$package,$sym) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1102 | 1 | my $ref = *{"$package\::$sym"}{ARRAY}; | |||||||||||||||||||||||||||||||||||||||||
| 1103 | 1 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | $this->throw( | |||||||||||||||||||||||||||||||||||||||||
| 1105 | 'PERL-00001: Array existiert nicht', | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | Error => $@, | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||
| 1110 | 1 | return $ref; | |||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||
| 1113 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | =head3 setArray() - Setze Package-Array auf Wert | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||
| 1119 | $ref = $this->setArray($package,$name,$ref); | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||
| 1121 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||
| 1123 | Setze Package-Array mit dem Namen $name auf den von $ref | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | referenzierten Wert, also auf @$ref und liefere eine Referenz | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | auf die Variable zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||
| 1127 | Die Methode kopiert den Wert, sie erzeugt keinen Alias! | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||
| 1129 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||
| 1131 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||
| 1135 | Setze Paket-Array 'a' auf den Wert @arr: | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||
| 1137 | $ref = Quiq::Perl->setArray($package,'a',\@arr); | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||
| 1139 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||
| 1141 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||
| 1143 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||
| 1145 | 2 | ▶ | sub setArray { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setArray: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1146 | 2 | my ($this,$package,$sym,$ref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||
| 1148 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1149 | 2 | @{"$package\::$sym"} = @$ref; | |||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||
| 1151 | 2 | return *{"$package\::$sym"}{ARRAY}; | |||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||
| 1154 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||
| 1156 | =head3 setScalar() - Setze Package-Skalar auf Wert | ||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||
| 1158 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||
| 1160 | $ref = $this->setScalar($package,$name,$val); | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||
| 1164 | Setze Package-Skalar mit dem Namen $name auf den Wert $val | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | und liefere eine Referenz auf die Variable zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||
| 1167 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||
| 1169 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||
| 1171 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||
| 1173 | Setze Paket-Skalar 'n' auf den Wert 99: | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||
| 1175 | $ref = $this->setScalar($package,n=>99); | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||
| 1177 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||
| 1179 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||
| 1181 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||
| 1183 | 3 | ▶ | sub setScalar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setScalar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1184 | 3 | my ($this,$package,$sym,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||
| 1186 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1187 | 3 | ${"$package\::$sym"} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 3 | return *{"$package\::$sym"}{'SCALAR'}; | |||||||||||||||||||||||||||||||||||||||||
| 1190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||
| 1192 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||
| 1194 | =head3 setScalarValue() - Setze Package-Skalar auf Wert | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||
| 1196 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||
| 1198 | $this->setScalarValue($package,$name=>$val); | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||
| 1200 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||
| 1202 | Setze Package-Skalar mit dem Namen $name auf den Wert $val. | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||
| 1204 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||
| 1206 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||
| 1208 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||
| 1210 | Setze Paket-Skalar 'n' auf den Wert 99: | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||
| 1212 | $ref = Quiq::Perl->setScalarValue($package,n=>99); | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||
| 1216 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||
| 1218 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | ▶ | sub setScalarValue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setScalarValue: not called CC=1 SCAR=0.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | my ($this,$package,$sym,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1224 | 270 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | ${"$package\::$sym"} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||
| 1232 | =head3 getScalarValue() - Liefere Wert von Package-Skalar | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||
| 1236 | $val = $this->getScalarValue($package,$name); | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||
| 1238 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||
| 1240 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||
| 1242 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||
| 1244 | Ermittele Wert von Paket-Skalar 'n': | ||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||
| 1246 | $val = Quiq::Perl->getScalarValue($package,'n'); | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||
| 1248 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||
| 1250 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||
| 1254 | 1 | ▶ | sub getScalarValue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getScalarValue: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1255 | 1 | my ($this,$package,$name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1258 | 270 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 1 | return ${"$package\::$name"}; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||
| 1262 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||
| 1264 | =head3 setVar() - Setze Package-Variable auf Wert | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||
| 1266 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||
| 1268 | $ref = $this->setVar($package,$sigil,$name,$ref); | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||
| 1272 | Setze Paketvariable vom Typ $sigil ('$', '@' oder '%') mit dem Namen | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | $name auf den von $ref referenzierten Wert (also $$ref | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | (falls Skalar) oder @$ref (falls Array) oder %$ref (falls Hash)) | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | und liefere eine Referenz auf die Variable zurück. | ||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||
| 1277 | Die Subroutine kopiert den Wert, sie erzeugt keinen Alias! | ||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||
| 1279 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||
| 1281 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||
| 1283 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||
| 1285 | Skalar | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||
| 1287 | $ref = Quiq::Perl->setVar($package,'$','s',\99); | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||
| 1289 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||
| 1291 | Array | ||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||
| 1293 | $ref = Quiq::Perl->setVar($package,'@','a',\@arr); | ||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||
| 1295 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||
| 1297 | Hash | ||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||
| 1299 | $ref = Quiq::Perl->setVar($package,'%','h',\%hash); | ||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||
| 1301 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||
| 1303 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||
| 1305 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||
| 1307 | 16 | ▶ | sub setVar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setVar: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1308 | 16 | my ($this,$package,$sigil,$sym,$ref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||
| 1310 | # Exception, wenn Sigil nicht korrekt | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | 16 | my $type = Quiq::Perl->sigilToType($sigil); | |||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||
| 1313 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1314 | 16 | ▶ | if ($sigil eq '$') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1315 | 2 | ${"$package\::$sym"} = $$ref; | |||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1317 | elsif ($sigil eq '@') { | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | 6 | @{"$package\::$sym"} = @$ref; | |||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1320 | elsif ($sigil eq '%') { | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | 8 | %{"$package\::$sym"} = %$ref; | |||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||
| 1324 | 16 | return *{"$package\::$sym"}{$type}; | |||||||||||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||
| 1327 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | =head3 getVar() - Liefere Referenz auf Package-Variable | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||
| 1331 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||
| 1333 | $ref = $this->getVar($package,$sigil,$name,@opt); | ||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||
| 1335 | =head4 Options | ||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||
| 1337 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||
| 1339 | =item -create => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||
| 1341 | Erzeuge Variable, falls sie nicht existiert. | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||
| 1343 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||
| 1345 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||
| 1347 | Liefere eine Referenz auf Package-Variable $name vom Typ $sigil | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | ('$','@' oder '%'). Existiert die Variable nicht, liefere undef. | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||
| 1350 | =head4 Caveats | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||
| 1352 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||
| 1354 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||
| 1356 | Skalare Variable | ||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||
| 1358 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||
| 1360 | Skalare Paketvariable, die mit "our" vereinbart sind und den Wert undef | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | haben, werden von der Funktion nicht erkannt bzw. nicht sicher | ||||||||||||||||||||||||||||||||||||||||||
| 1362 | erkannt (Grund ist unklar). Mit "our" vereinbarte skalare | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | Paketvariable mit definiertem Wert werden sicher erkannt. Workaround: | ||||||||||||||||||||||||||||||||||||||||||
| 1364 | Skalare Paketvariable, die mit der Methode abgefragt werden sollen, | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | auch wenn sie den Wert undef haben, mit "use vars" vereinbaren. | ||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||
| 1367 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||
| 1369 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||
| 1371 | 170 | ▶ | sub getVar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getVar: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1372 | 170 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1373 | 170 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1374 | 170 | my $sigil = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1375 | 170 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||
| 1377 | 170 | my $type = Quiq::Perl->sigilToType($sigil); | |||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||
| 1379 | 170 | my $create = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1380 | 170 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1381 | 24 | Quiq::Option->extract(\@_, | |||||||||||||||||||||||||||||||||||||||||
| 1382 | -create => \$create, | ||||||||||||||||||||||||||||||||||||||||||
| 1383 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||
| 1386 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||
| 1388 | 170 | ▶ | if (!$create) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1389 | # Zunächst auf Symboltabelleneintrag testen. Wenn keiner | ||||||||||||||||||||||||||||||||||||||||||
| 1390 | # existiert, gibt es die Variable nicht. Ohne diesen Test | ||||||||||||||||||||||||||||||||||||||||||
| 1391 | # würden Symboltabelleneinträge durch den darauffolgenden Code | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | # angelegt werden. | ||||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||
| 1394 | 146 | ▶ | return undef if !exists ${"$package\::"}{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||
| 1396 | 99 | ▶ | if ($type eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1397 | 6 | ▶ | if (!defined ${"$package\::$name"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1398 | 270 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1399 | # Unterdrücke 'Variable "..." not imported' Warnungen, | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | # die neben der Exception generiert werden. | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | 4 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1402 | 4 | eval "package $package; \$$name"; | |||||||||||||||||||||||||||||||||||||||||
| 1403 | 4 | ▶ | return undef if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||||||||||||||||
| 1408 | 121 | my $ref = *{"$package\::$name"}{$type}; | |||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||
| 1410 | # Wenn $create "wahr", Variable erzeugen, falls nicht existent | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||
| 1412 | 121 | ▶ | if (!$ref && $create) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $ref and $create
MC/DC100%2/2
not $ref and $create
not $ref
$create
Truth table100%3/3
not(A) and B
A= not $refB= $create
| |||||||||||||||||||||||||||||||||||||||||||
| 1413 | $ref = $this->setVar($package,$sigil,$name, | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | 10 | {'$'=>\undef,'@'=>[],'%'=>{}}->{$sigil}); | |||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||
| 1417 | 121 | return $ref; | |||||||||||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||
| 1420 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||
| 1422 | =head3 setSubroutine() - Setze Package-Subroutine auf Wert | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||
| 1424 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||
| 1426 | $ref = $this->setSubroutine($package,$name=>$ref); | ||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||
| 1428 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||
| 1430 | Referenz auf die Subroutine. | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||
| 1432 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||
| 1434 | Füge Subroutine $ref zu Package $package unter dem Namen $name hinzu. | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | Existiert eine Package-Subroutine mit dem Namen bereits, | ||||||||||||||||||||||||||||||||||||||||||
| 1436 | wird diese ersetzt. | ||||||||||||||||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||||||||||||||||
| 1438 | =head4 Examples | ||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||
| 1440 | Definition: | ||||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||
| 1442 | $ref = Quiq::Perl->setSubroutine('My::Class',m=>sub {...}); | ||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||
| 1444 | Aufruf: | ||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||
| 1446 | My::Class->m(...); | ||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||
| 1448 | oder | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||
| 1450 | $ref->(...); | ||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||
| 1452 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||
| 1454 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||||||||||
| 1456 | 4 | ▶ | sub setSubroutine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setSubroutine: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1457 | 4 | my ($this,$package,$name,$ref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||
| 1459 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1460 | 270 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1461 | 4 | return *{"$package\::$name"} = $ref; | |||||||||||||||||||||||||||||||||||||||||
| 1462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||
| 1464 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||
| 1466 | =head3 getSubroutine() - Liefere Referenz auf Subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||
| 1468 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||
| 1470 | $ref = $this->getSubroutine($package,$name); | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||
| 1472 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||
| 1474 | Liefere Referenz auf Subroutine $name in Package $package. Enthält | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | das Package keine Subroutine mit dem Namen $name, liefere undef. | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||
| 1477 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||
| 1479 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||
| 1481 | 8 | ▶ | sub getSubroutine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getSubroutine: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1482 | 8 | my ($this,$package,$name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||||||||||||||||
| 1484 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1485 | 8 | ▶ | if (defined *{"$package\::$name"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1486 | 2 | return *{"$package\::$name"}{CODE}; | |||||||||||||||||||||||||||||||||||||||||
| 1487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||
| 1489 | 6 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||
| 1492 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||
| 1494 | =head2 Suchpfade | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||
| 1496 | =head3 basicIncPaths() - Grundlegende Modul-Suchpfade | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||
| 1498 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||
| 1500 | @paths|$pathA = $class->basicIncPaths; | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||
| 1502 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||
| 1504 | Liefere die Liste der I<grundlegenden> Suchpfade des aktuell laufenden | ||||||||||||||||||||||||||||||||||||||||||
| 1505 | Perl-Interpreters. Ergänzungen durch | ||||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||
| 1507 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||
| 1509 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||
| 1511 | -II<path> | ||||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||
| 1513 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||
| 1515 | PERLLIB | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||
| 1517 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||
| 1519 | PERL5LIB | ||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||
| 1521 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||
| 1523 | use lib (I<@paths>) | ||||||||||||||||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||||||||||||||||
| 1525 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||
| 1527 | usw. | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||||||||||||||||
| 1529 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||||||||||||||||
| 1531 | sind I<nicht> enthalten. | ||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||
| 1533 | Die Liste entspricht dem Ergebnis des Aufrufs | ||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||
| 1535 | $ PERLLIB= PERL5LIB= perl -le 'print join "\n",@INC' | ||||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||
| 1537 | =head4 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||
| 1539 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||
| 1541 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||
| 1543 | L<additionalIncPaths|"additionalIncPaths() - Zusätzliche Modul-Suchpfade">() | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||
| 1545 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||
| 1547 | L<incPaths|"incPaths() - Alle Modul-Suchpfade">() | ||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||
| 1549 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||
| 1551 | =head4 Example | ||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||
| 1553 | Quiq::Perl->basicIncPaths; | ||||||||||||||||||||||||||||||||||||||||||
| 1554 | ==> | ||||||||||||||||||||||||||||||||||||||||||
| 1555 | /etc/perl | ||||||||||||||||||||||||||||||||||||||||||
| 1556 | /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 | ||||||||||||||||||||||||||||||||||||||||||
| 1557 | /usr/local/share/perl/5.20.2 | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | /usr/lib/x86_64-linux-gnu/perl5/5.20 | ||||||||||||||||||||||||||||||||||||||||||
| 1559 | /usr/share/perl5 | ||||||||||||||||||||||||||||||||||||||||||
| 1560 | /usr/lib/x86_64-linux-gnu/perl/5.20 | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | /usr/share/perl/5.20 | ||||||||||||||||||||||||||||||||||||||||||
| 1562 | /usr/local/lib/site_perl | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | . | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||
| 1565 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||
| 1567 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||
| 1569 | 270 | my @Paths; | |||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||
| 1571 | 1 | ▶ | sub basicIncPaths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
basicIncPaths: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1572 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||||||||||||||||
| 1574 | 1 | ▶ | if (!@Paths) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1575 | 1 | my $cmd = qq|PERLLIB= PERL5LIB= $^X -e 'print join "\n",\@INC'|; | |||||||||||||||||||||||||||||||||||||||||
| 1576 | 1 | @Paths = split /\n/,qx/$cmd/; | |||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||
| 1579 | 1 | ▶ | return wantarray? @Paths: \@Paths; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1580 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||
| 1582 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||
| 1584 | =head3 additionalIncPaths() - Zusätzliche Modul-Suchpfade | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||
| 1586 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | |||||||||||||||||||||||||||||||||||||||||||
| 1588 | @paths|$pathA = $class->additionalIncPaths; | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||||||||||
| 1590 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||
| 1592 | Liefere die zusätzlichen Suchpfade des aktuell laufenden | ||||||||||||||||||||||||||||||||||||||||||
| 1593 | Perl-Programms, also die Suchpfade, die über die grundlegenden | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | Suchpfade des Perl_interpreters hinausgehen. | ||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||
| 1596 | =head4 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||
| 1598 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||
| 1600 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||||||||||
| 1602 | L<basicIncPaths|"basicIncPaths() - Grundlegende Modul-Suchpfade">() | ||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||
| 1604 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||
| 1606 | L<incPaths|"incPaths() - Alle Modul-Suchpfade">() | ||||||||||||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||||||||||||
| 1608 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||||||||||||
| 1610 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||
| 1612 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | ▶ | sub additionalIncPaths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
additionalIncPaths: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | my %path; | |||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | @path{@INC} = (1) x @INC; | |||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | for ($class->basicIncPaths) { | |||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | delete $path{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | my @paths = keys %path; | |||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | ▶ | return wantarray? @paths: \@paths; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||
| 1627 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||
| 1629 | =head3 incPaths() - Alle Modul-Suchpfade | ||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||
| 1631 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||
| 1633 | @paths|$pathA = $class->incPaths; | ||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||
| 1635 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||||||||||||||||
| 1637 | Liefere I<alle> Suchpfade des aktuell laufenden Perl-Programms, | ||||||||||||||||||||||||||||||||||||||||||
| 1638 | also die Werte des @INC-Arrays Im Skalar-Kontext liefere eine | ||||||||||||||||||||||||||||||||||||||||||
| 1639 | Referenz auf das Array. | ||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||
| 1641 | =head4 See Also | ||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||
| 1643 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||
| 1645 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||
| 1647 | L<basicIncPaths|"basicIncPaths() - Grundlegende Modul-Suchpfade">() | ||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||
| 1649 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||||||||||||
| 1651 | L<additionalIncPaths|"additionalIncPaths() - Zusätzliche Modul-Suchpfade">() | ||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||
| 1653 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||
| 1655 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||
| 1657 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1658 | |||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | sub incPaths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
incPaths: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | ▶ | return wantarray? @INC: \@INC; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||
| 1664 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1665 | |||||||||||||||||||||||||||||||||||||||||||
| 1666 | =head2 POD | ||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||
| 1668 | =head3 getPod() - Extrahiere POD-Dokumentation aus Perl-Quelltext | ||||||||||||||||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||||||||||||||||
| 1670 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | |||||||||||||||||||||||||||||||||||||||||||
| 1672 | $pod = $this->getPod($file); | ||||||||||||||||||||||||||||||||||||||||||
| 1673 | $pod = $this->getPod(\$text); | ||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||
| 1675 | ($pod,$encoding) = $this->getPod($file); | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | ($pod,$encoding) = $this->getPod(\$text); | ||||||||||||||||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||||||||||||||||
| 1678 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1679 | |||||||||||||||||||||||||||||||||||||||||||
| 1680 | Lies den POD-Code aus Datei $file bzw. Quelltext $text und liefere | ||||||||||||||||||||||||||||||||||||||||||
| 1681 | diesen zurück. Ist ein Encoding definiert, dekodiere den | ||||||||||||||||||||||||||||||||||||||||||
| 1682 | gelieferten POD-Code entsprechend. Im Array-Kontext liefere | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | zusätzlich zum POD-Code das Encoding. | ||||||||||||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||||||||||||
| 1685 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||
| 1687 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | ▶ | sub getPod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPod: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | my ($this,$input) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | my $pod = ''; | |||||||||||||||||||||||||||||||||||||||||
| 1693 | |||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | my $inPod = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | my $fh = Quiq::FileHandle->new('<',$input); | |||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | ▶ | if (/^=cut/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | $inPod = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1701 | elsif (/^=[a-z]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | $inPod = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | ▶ | if ($inPod) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | $pod .= $_; | |||||||||||||||||||||||||||||||||||||||||
| 1706 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1708 | 0 | $fh->close; | |||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||
| 1710 | 0 | $pod =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | $pod .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||
| 1713 | 0 | my ($encoding) = $pod =~ /^=encoding\s+(\S+)/m; | |||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | ▶ | if ($encoding) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | $pod = Encode::decode($encoding,$pod); | |||||||||||||||||||||||||||||||||||||||||
| 1716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1717 | |||||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | ▶ | return wantarray? ($pod,$encoding): $pod; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||
| 1721 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||||||||||
| 1723 | =head3 getPodValues() - Liefere Content von POD-Abschnitten | ||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||
| 1725 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1726 | |||||||||||||||||||||||||||||||||||||||||||
| 1727 | $this->getPodValues($file,@keyRef); | ||||||||||||||||||||||||||||||||||||||||||
| 1728 | $this->getPodValues(\$text,@keyRef); | ||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||
| 1730 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||||||||||||
| 1732 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||
| 1734 | 0 | ▶ | sub getPodValues { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPodValues: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1735 | 0 | my ($this,$input,%keyRef) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | my $pod = $this->getPod($input); | |||||||||||||||||||||||||||||||||||||||||
| 1738 | 0 | for my $key (keys %keyRef) { | |||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | my $ref = $keyRef{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | ▶ | if ($$ref) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 1742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1743 | 0 | my ($val) = $pod =~ /(?:^|\n\n)=head1 $key\n\n(.*?)(\n\n=head1|$)/s; | |||||||||||||||||||||||||||||||||||||||||
| 1744 | 0 | ▶ | if (defined($val) && $val ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $val and $val ne ""
MC/DC0%0/2
defined $val and $val ne ""
defined $val
$val ne ""
Truth table0%0/3
A and B
A= defined $valB= $val ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 1745 | 0 | $$ref = $val; | |||||||||||||||||||||||||||||||||||||||||
| 1746 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1747 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||
| 1749 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1750 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||
| 1752 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||||||||||
| 1754 | =head3 removePod() - Entferne POD-Abschnitte aus Quelltext | ||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||
| 1756 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||
| 1758 | $newCode = $this->removePod($code); | ||||||||||||||||||||||||||||||||||||||||||
| 1759 | $this->removePod(\$code); | ||||||||||||||||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||||||||||||||||
| 1761 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||
| 1763 | Entferne alle POD-Abschnitte aus dem Quelltext $code und liefere | ||||||||||||||||||||||||||||||||||||||||||
| 1764 | den resultierenden Quelltext zurück. Wird eine Referenz auf | ||||||||||||||||||||||||||||||||||||||||||
| 1765 | den Quelltext übergeben, erfolgt die Manipulation in-place. | ||||||||||||||||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||||||||||||||||
| 1767 | Auf den POD-Abschnitt folgende Leerzeilen (die außerhalb des | ||||||||||||||||||||||||||||||||||||||||||
| 1768 | POD-Code liegen) werden ebenfalls entfernt. | ||||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||
| 1770 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||
| 1772 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||||||||||
| 1774 | 1 | ▶ | sub removePod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
removePod: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1775 | 1 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1776 | 1 | ▶ | my $ref = ref $_[0]? shift: \shift; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||
| 1778 | 1 | $$ref =~ s/^=[a-z].*?^=cut\n*//msg; | |||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||
| 1780 | 1 | return $$ref; | |||||||||||||||||||||||||||||||||||||||||
| 1781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||
| 1783 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||||||||||||||||
| 1785 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||||||||||||||||
| 1787 | 1.240 | ||||||||||||||||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||||||||||||||||
| 1789 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||||||||||||||||
| 1791 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | |||||||||||||||||||||||||||||||||||||||||||
| 1793 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||||||||||||||||
| 1795 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||
| 1797 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||
| 1799 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 1800 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||||||||||||||||
| 1802 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1803 | |||||||||||||||||||||||||||||||||||||||||||
| 1804 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||
| 1806 | 270 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||||||||||||
| 1808 | # eof | ||||||||||||||||||||||||||||||||||||||||||