Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perlian,
How come my code below doesn't update the original
hash (%line)?
Such that finally the %line will give:my %line = ('A' =>1, 'B' =>1, 'C' =>1); my @tojoin = qw (W X Y Z); foreach my $line ( keys %line ) { print "$line\n"; foreach my $tojoin ( @tojoin ) { my $nstr = $line.$tojoin; $line{$nstr} = 1; } last if ($line eq 'AYW'); }
A => 1, B => 1, C => 1, AW => 1, .... until AYW => 1
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Updating A Hash Recursively
by ChemBoy (Priest) on Sep 05, 2005 at 06:21 UTC | |
by Anonymous Monk on Sep 06, 2005 at 01:55 UTC | |
Re: Updating A Hash Recursively
by GrandFather (Saint) on Sep 05, 2005 at 05:40 UTC | |
Re: Updating A Hash Recursively
by gargle (Chaplain) on Sep 05, 2005 at 05:43 UTC | |
Re: Updating A Hash Recursively
by NetWallah (Canon) on Sep 05, 2005 at 06:11 UTC | |
Re: Updating A Hash Recursively
by QM (Parson) on Sep 06, 2005 at 17:56 UTC |
Back to
Seekers of Perl Wisdom