Thread Komplexe Datenstruktur in Perl aufbauen
(29 answers)
Opened by Matthias at 2010-02-26 12:54
OK, zweite Tiefenebene war schon korrekt.
ABER! Das wesentliche ist nicht die Verwendung von exists sondern die Verwendung von && wenn man in der Tiefe abfragt! Dann klappt es auch ohne autovivi: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; if (exists $hash{a} && exists $hash{a}{b}) {} print "Case 1 without autovivication:\n" , Dumper \%hash; if (exists $hash{a}{b}) {} print "Case 2 with autovivication:\n" , Dumper \%hash; 10 print "Hallo"
20 goto 10 |