Leser: 2
![]() |
|< 1 2 >| | ![]() |
15 Einträge, 2 Seiten |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/perl use strict; use warnings; my %hash = ( '[foo]' => [3], '[bar]' => [2], '[buz]' => [1], '[qiz]' => [undef], ); print 'K: '. $_ .' V: '. $hash{$_}->[0] . "\n" for sort { $hash{$a}->[0] <=> $hash{$b}->[0] } grep { defined $hash{$_}->[0] } keys %hash;
sort { $hash{$a}->[0] <=> $hash{$b}->[0] or $a cmp $b }
1
2
3
4
5
6
7
for my $k (sort { $hash{$a}->[0] <=> $hash{$b}->[0] or $a cmp $b } keys %hash) {
my @arr = grep { defined $_ } @{ $hash{$k} };
if (@arr) {
printf "%-25s : %-80s\n", $k, "@arr";
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/perl use strict; use warnings; my %hash = ( key1 => ['dies'], ist => ['ein'], Test => ['hallo'], was => ['wert'], los => ['hash'], ); for my $k (sort { $hash{$a}->[0] cmp $hash{$b}->[0] or $a cmp $b } keys %hash) { my @arr = grep { defined $_ } @{ $hash{$k} }; if (@arr) { printf "%-25s : %-80s\n", $k, "@arr"; } }
![]() |
|< 1 2 >| | ![]() |
15 Einträge, 2 Seiten |