Leser: 22
1 2 3 4 5 6 7
my %hosts; # iterieren über zeilen # extrahieren von host, user, tp, ... push @{ $hosts{ $host } }, { user => $user, tp => $tp, };
1 2 3
# iterieren über zeilen # extrahieren von host, user, tp, ... $hosts{ $host }->{ $user }->{ $tp } = ...;
if(defined $hosts{'HostName'}->{'Programmname'})
1 2 3 4 5
$hosts{ $host }->{TP}->{ $tp } = 1; # später if (exists $hosts{"example.org"}->{TP}->{blubb}) { ... }
1 2 3 4 5 6 7 8 9 10 11 12 13
my %hosts; push @{ $hosts{ 'TestHost' } }, { user => 'TestUser', }; use Data::Dumper; print Dumper \%hosts; $hosts{ 'TestHost' }->{TP}->{ 'TestAnwendung' } = 1; use Data::Dumper; print Dumper \%hosts;
$hosts{ $host }->{TP}->{ $tp } = 1;
$hosts{ $host }->{USER}->{ $user } = 1;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
sub AddUpdateDataSet($;$;$;$) { if(defined $Host_Records{$_[0]}){ print $_[0]." already exists.\n"; } else { $Host_Records{ $_[0] } = 1; if(defined $Host_Records{$_[0]}->{TP}->{$_[1]}) { print "TP does exist\n"; } else { print "TP update\n"; $Host_Records{$_[0]}->{TP}->{$_[1]} = 1; }#else if(defined $Host_Records{$_[0]}->{USERHOST}->{$_[2]}) { print "USERHOST does exist\n"; } else { print "USERHOST update\n"; $Host_Records{$_[0]}->{USERHOST}->{$_[2]} = 1; }#else if(defined $Host_Records->{USER}->{$_[3]}) { print "USER does exist\n"; } else { print "USER update\n"; $Host_Records{$_[0]}->{USER}->{$_[3]} = 1; }#else }#else }#CheckHost
1 2 3 4 5
# iteriere über jede zeile $hosts{ $host }->{TP}->{ $tp } = 1; $hosts{ $host }->{USER}->{ $user } = 1; $hosts{ $host }->{USERHOST}->{ $userhost } = 1; ...
1 2 3 4 5 6
foreach $host (keys %Host_Records) { #print "Zusammenfassung für Host: ".$host."\n"; foreach $tp (keys %Host_Records{TP}) { print $tp; } }
1 2 3 4 5 6 7
foreach $host (keys %Host_Records) { print "Zusammenfassung für Host: ".$host."\n"; my $tps = $Host_Records{TP}->{$host}; foreach $tp (keys %$tps) { print "Programm: ".$tp."\n"; } }
Guest KaiDer Rumpf der 2ten foreach-Schleife wird nicht angesprungen.
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
$VAR1 = {
'sapap12.ka.de.com (sapap12) (172.23.88.136)' => {
'TP' => {
'sapxp' => 1
},
'USERHOST' => {
'sapapyy.ka.de.yyyyy.com' => 1,
'sapapxx.ka.de.xxxxx.com' => 1
},
'USER' => {
'CPICUC4' => 1,
'TMSADM' => 1
}
},
'sapap11.ka.de.com (sapap11) (172.23.88.136)' => {
'TP' => {
'Anwendun' => 1,
'/usr/sap/AP1/D57/exe/t' => 1,
'rfcexe' => 1
},
'USERHOST' => {
'sapap11.ka.de.xxxxx.com' => 1
},
'USER' => {
'DDIC' => 1,
'TMSADM' => 1
}
}
};
push @{ $Host_Records{ $host}->{USER}{$user}, $_[1];
Guest KaiEine letzte Frage noch...
Code (perl): (dl )push @{ $Host_Records{ $host}->{USER}{$user}, $_[1];
Wie kann man dieses Array auslesen?
1 2 3 4 5
print join ", ", @array; foreach my $item (@array) { ... } print join ", ", @{ $Host_Records{ $host }->{USER}->{ $user } }; foreach my $item (?????????) { ... }