Thread Speichern von Daten aus array in Hash: %hash und @array/aref (6 answers)
Opened by Duff at 2007-05-25 16:48

pq
 2007-05-26 12:52
#76964 #76964
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
[quote=PerlProfi,25.05.2007, 17:34]Ansonsten kriegst du einen Fehler, falls die Values von deinem Hash keine Arrayreferenzen enthalten, wenn du den push() machst.[/quote]
das stimmt so nicht. ist ein hash-value undef, dann erstellt perl das array
on-the-fly, wenn man ein push macht.
siehe
Code: (dl )
1
2
3
4
$ perl -Mstrict -wle'
my %hash = ( key => undef);
push @{ $hash{key} }, 23;'
$
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread Speichern von Daten aus array in Hash: %hash und @array/aref