Thread Hashes in Array
(4 answers)
Opened by Moritz at 2013-01-09 17:27
indem Du die Hashreferenz im Array-Element derefernzierst, z.B. so:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 use strict; use warnings; my @array; my %hash = (a => 1, b => 5, c => 11); $array[1] = \%hash; print "flat list:\n"; print join("\n",%{$array[1]}); print "\n\nkey-value-pairs:\n"; for my $k (keys %{$array[1]}) { print "$k => " . $array[1]->{$k} ."\n"; } Ausgabe: Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"
|