Thread Frage zu Hash (15 answers)
Opened by jason-duff at 2006-01-16 12:13

jason-duff
 2006-01-17 14:10
#61943 #61943
User since
2005-10-11
23 Artikel
BenutzerIn
[default_avatar]
hallo Leute habe dass problem jetzt so gelöst. Ist vielleicht nicht wirklich schön aber es funzt. genau so wollte ich es haben. man kann es mit sicherheit auch besser machen.
Code: (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
my %relationen = (
 'jittermaxnegsd'=>{'rel'=>'jittermaxpossd','func'=>\&jitter_out},
 'jittermaxpossd'=>{'rel'=>'jittermaxnegsd','func'=>\&jitter_out},
 'packetlossin'  =>{'rel'=>'packetlossout' ,'func'=>\&packet_loss},
 'packetlossout' =>{'rel'=>'packetlossin'  ,'func'=>\&packet_loss},

);

my %nonrelation = (
 'traffic' => \&traffic,
 'cpu' => \&cpu,
);

foreach my $path(keys(%dirs)){

 my @pathitems =(split (/\//,$path));
 my $typ =$pathitems[-1];

 if (exists $relation{$typ})
  {
    $pathitems[-1]=$relation{$typ}{'rel'};
    my $path2 = join('/',@pathitems);
       
    $relation{$typ}{'func'}($path,$dirs{$path},$path2,$dirs{$path2});
 
  }else{ $nonrelation{$typ}($path,$dirs{$path});}

}


%dirs ist ein Hash der Form

%dirs =( './cisco-items/smfdsdn4/packetlossout' =>\@array,
         ./cisco-items/smfdsdn4/packetlossin'=> \@array,
         ./cisco-items/smfdsdn3/s0/traffic'=> \@array;
         usw...
      )\n\n

<!--EDIT|jason-duff|1137500800-->

View full thread Frage zu Hash