Madam has asked for the wisdom of the Perl Monks concerning the following question:
Hi PerlMonks,
In a 'foreach' loop ,i am appending the hash.but it is taking the last values,the intial elements are not getting added.
i.e,
only "yellow" is getting printed. where am i going wrong? Thanks, Madammy @array = ("white","blue","yellow"); my %hash = (); foreach my $temp (@array) { %hash = ($temp => $temp); } print keys %hash;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Hash not getting updated
by blazar (Canon) on Apr 29, 2005 at 08:21 UTC | |
Re: Hash not getting updated
by davidj (Priest) on Apr 29, 2005 at 08:30 UTC | |
Re: Hash not getting updated
by monkfan (Curate) on Apr 29, 2005 at 13:52 UTC | |
Re: Hash not getting updated
by CharlesClarkson (Curate) on Apr 30, 2005 at 07:04 UTC | |
by Madam (Sexton) on May 03, 2005 at 06:34 UTC | |
by CharlesClarkson (Curate) on May 03, 2005 at 14:23 UTC | |
Re: Hash not getting updated
by gube (Parson) on Apr 30, 2005 at 01:22 UTC |
Back to
Seekers of Perl Wisdom