Thread Sortierte Ausgabe Hash in hash in hash (3 answers)
Opened by Franz at 2007-01-31 15:41

renee
 2007-01-31 16:08
#73877 #73877
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
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
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl

use strict;
use warnings;

my %dienste=(
"z" => {
"y" => {
"x" => {
"fields" => {
"a" => {
"order" => "03",
"content" => "n"
},
"b" => {
"order" => "02",
"content" => "u"
},
"c" => {
"order" => "01",
"content" => "h"
},
"d" => {
"order" => "04",
"content" => "d"
}
}
}
}
}
);

my $hashref = $dienste{z}->{y}->{x}->{fields};
my @sorted = sort{$hashref->{$a}->{order} <=> $hashref->{$b}->{order} }keys %$hashref;

for my $key(@sorted){
print sprintf "%s -- %s\n",$hashref->{$key}->{order}, $hashref->{$key}->{content};
}
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Sortierte Ausgabe Hash in hash in hash