On Mon, 12 Aug 2002, Theuerkorn Johannes wrote: > Hi there, > > I still got Problems with hashes. > > I have the following code: > > Now i want to call the Sub not onla once, but I donīt want to lose the previous >Values, so I tried this in the sub: > > push @{$ergebnis{$seriennr}}, >{tstamp=>@tstamp_board,serial=>@serial,retests=>@retests,fwrev=>@fwrev,hwrev=>@hwrev,hp79k=>@hp79k,platz=>@platz,passfail=>@passfail};
Phew!! after all those arrays finally a hash :-) tstamp=>@tstamp_board will not work the way you are expecting it to. Run this piece of code and see for yourself. The value to a hash key can only be a scalar. use strict; use Data::Dumper; my @tstamp_board = (1, 2, 3); my %ergebnis = (tstamp => @arr); print Dumper(\%ergebnis); What you need is to store the reference of @tstamp_board in tstamp. tstamp => [@tstamp_board] If @tstamp_board is not being my'ed in the loop everytime a \@tstamp_board will result in shallow copying. So, don't do that http://www.stonehenge.com/merlyn/UnixReview/col30.html > > But if I try to read the Values from it: > > my $erg= $ergebnis{$seriennr}; $ergebnis{$seriennr} is a reference to an array of hashes or hash references. > > print $$erg->{passfail}[0]; This should be like this print $erg->[0]{passfail}; You will have to get to the array before getting to the hashes, a lot like your post :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]