Thread Zweistufige Hash-Referenz zuweisen
(36 answers)
Opened by mikdoe at 2009-06-03 20:50
Script nach wie vor wie folgt und Daten keine echten Daten.
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 my @keys = keys (%$hash_ref); foreach my $k (sort {lc $keys[$a] cmp lc $keys[$b]} 0..$#keys) { print "$keys[$k] => "; if (ref($hash_ref -> {$keys[$k]}) eq 'ARRAY') { print "(Untermenge wie folgt:)\n"; # my @keys2 = keys %{$hash_ref -> {$keys[$k]}}; my @keys2 = $hash_ref -> {$keys[$k]}; foreach my $k2 (sort {lc $keys2[$a] cmp lc $keys2[$b]} 0..$#keys2) { print "\t\t$keys2[$k2] => " . (defined $hash_ref -> {$keys2[$k2]} -> {$keys2[$k2]} ? $hash_ref -> {$keys2[$k2]} -> {$keys2[$k2]} : 'NOT DEFINED') . "\n"; } } else { print (defined $hash_ref -> {$keys[$k]} ? $hash_ref -> {$keys[$k]} : 'NOT DEFINED'); } print "\n"; } Danke |