Thread Array als Keys im Hash nutzen
(8 answers)
Opened by Hagen at 2019-02-13 10:34
Sowas vielleicht
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 my @keys = ('level1_1', 'level2_1', 'level3_1'); my %hash = (); $hash{data} = {}; my $hashref = $hash{data}; for my $i (0..$#keys) { $hashref->{$keys[$i]} = ($i == $#keys ? 'test' : {}); $hashref = $hashref->{$keys[$i]}; } print "Dumper: '".Dumper(\%hash)."'<br>\n"; Last edited: 2019-02-13 10:59:05 +0100 (CET) 1 + 1 = 10
|