1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package Kernel::Config;
use strict;
use warnings;
use base qw( Kernel::Config::Defaults );
# --------------------------------------------------------------------------------------------------------------------------------------------------------
sub Config_Loader {
my ( $Typ, %Parameter ) = @_;
my $Self = { };
bless( $Self , $Typ );
# --------------------------------------------------------------------------------------------------------------------------------------------------------
$Self -> { Home } = 'E:/Programmierung/Aktuell';
$Self -> { Debug_Modus } = 'N';
$Self -> Defaults_Loader( \$Self );
# --------------------------------------------------------------------------------------------------------------------------------------------------------
# Rückgabe der Config - Werte
return $Self;
}
my $Self = { };
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#!/usr/bin/perl use warnings; use strict; package Kernel::Config::Defaults { sub new { my $classname = shift; my $self = {}; return bless($self, $classname); } sub Defaults_Loader { my $self = shift; my $kernelConfig = shift; print $kernelConfig->{home} . "\n"; } } package Kernel::Config { use base 'Kernel::Config::Defaults'; sub Config_Loader { my $self = shift; $self->{home} = 'E:/Programmierung/Aktuell'; $self->{debug_modus} = 'N'; $self->Defaults_Loader($self); } } my $kc = Kernel::Config->new(); $kc->Config_Loader();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sub new {
my ( $Type , %Param ) = @_;
my $Self = bless { } , $Type;
for my $Parameter ( sort keys %Param )
{
$Self -> { Parameter } -> { $Parameter } = $Param{ $Parameter };
}
return $Self;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sub Builder {
my ( $Self , %Parameter ) = @_;
my $OM_Package = $Parameter{ Package };
my $OM_FH = $OM_Package;
$OM_FH =~ s{::}{/}g;
$OM_FH .= '.pm';
eval { require $OM_FH; };
my $OM_Objects = $OM_Package -> New( %{ $Self -> { Parameter } -> { $OM_Package } // { } } );
$Self -> { Objects } -> { $OM_Package } = $OM_Objects;
return $OM_Objects;
}
1
2
3
4
5
6
7
my $Config = $OM -> Load( 'Kernel::Config' );
...
print "Eintrag aus Config : " . $Config -> { Home } . "\n";
print "Eintrag aus Defaults : " . $Config -> { Defaults } . "\n";