Thread Unbestimmt tiefen HashinHash erzeugen
(14 answers)
Opened by scriptor at 2009-08-09 00:58
So geht´s:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 sub hash { my ($ref, $hash) = @_; for my $el (@$ref) { $hash = $hash->{$el} ||= {}; } } my $h = {}; my @array = qw/ a b c d e /; hash( \@array, $h); print Dumper( $h ); Egebnis: |