Thread Übergabe Hash-Struktur an Methode
(33 answers)
Opened by mtbf40 at 2015-05-19 15:44 2015-05-20T15:33:50 mtbf40 Och, das geht schon: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 #!/usr/bin/perl use warnings; use strict; package childmodul; sub new { my $classname = shift; my $self = {hsh_scriptParam => shift}; return bless($self, $classname); } sub set_Data { my $self = shift; my $args = {@_}; my $i; my %h = %{$self->{hsh_scriptParam}}; print $h{DBParam}->{dbSession}->{runtime}->{dbTable}; print "\n"; my %h2 = %{$args}; print $h2{wert} . "\n"; $h{DBParam}->{dbSession}->{runtime}->{dbTable} = $h2{wert}; $self->showResult(); } sub showResult { my $self = shift; my %h = %{$self->{hsh_scriptParam}}; print "Result: "; print $h{DBParam}->{dbSession}->{runtime}->{dbTable}; print "\n"; } package main; my $hsh_runtimeParam = { ScriptParam => {ScriptName => $0 || '???', Version => 'v.01' || '???', Hilfe => {Usage => 'ruf mich mal richtig auf', Message => 'rufe mal nach Mutti'}, }, Runtime => {ApplName => 'TestClass', Caller => $^O =~ /win32/i ? $ENV{USERNAME} : $ENV{USER}, Loglevel => 'höher geht nicht', RootPath => 'ganz oben' || '???', StartTime => 'am Anfang' || '???', }, DBParam => {RegPar => 'test', dbSession => {ApplName => 'testhash', Action => 'insert', runtime => {dbTable => 'INIT_REG'} } } }; my $Object1 = childmodul->new($hsh_runtimeParam); $Object1->set_Data(block => {test => [ 'DBParam', 'dbSession', 'runtime' ]}, key => 'dbTable', wert =>'INIT_RUN'); |