http://www.perlmonks.org?node_id=489142

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)?
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'); }
Such that finally the %line will give:
A => 1, B => 1, C => 1, AW => 1, .... until AYW => 1