breeze has asked for the wisdom of the Perl Monks concerning the following question:
Hi!
I use perl 5.10.1_5 at FreeBSD and try execute this code:
#!/usr/bin/perl use utf8; use Encode; use strict; use warnings; use Data::Dumper; my $locale = "EN"; my $setSwitchName = "UNINSTALL"; my $content = { 'EN' => { 'SWITCH' => { 'INSTALL' => { 'ACTION' => 'a1', 'ICONID' => 'i1', 'CAPTION' => 'c1', 'DIZ' => 'd1' }, 'UNINSTALL' => { 'ACTION' => 'a2', 'ICONID' => 'i2', 'CAPTION' => 'c2', 'DIZ' => 'd2' } }, 'ACTION' => 'a3', 'ICONID' => 'i3', 'CAPTION' => 'c3', 'DIZ' => 'd3' } }; my $switchValues = $content->{$locale}->{'SWITCH'}; print ("switchValues=".Dumper($switchValues)."\n"); my $setSwitchValue = $switchValues->{$setSwitchName}; my $tmpContent = $setSwitchValue; $tmpContent->{'SWITCH'} = $switchValues; my $newContent->{$locale} = $tmpContent; print ("newContent=".Dumper($newContent));
I wanna create new HASH with changed part defined by $setSwitchName, but when i look at th e dump of $newContent i see next:
newContent=$VAR1 = { 'EN' => { 'SWITCH' => { 'INSTALL' => { 'ACTION' => 'a1', 'ICONID' => 'i1', 'DIZ' => 'd1', 'CAPTION' => 'c1' }, 'UNINSTALL' => $VAR1->{'EN'} }, 'ACTION' => 'a2', 'ICONID' => 'i2', 'DIZ' => 'd2', 'CAPTION' => 'c2' } };
Why the value of 'UNINSTALL' is $VAR1->{'EN'} ???
I Am doing something wrong or is this a problem in Perl or what?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl. Problem with HASH value
by choroba (Cardinal) on Dec 16, 2011 at 18:17 UTC | |
by breeze (Initiate) on Dec 16, 2011 at 20:12 UTC | |
|
Re: Perl. Problem with HASH value
by Anonymous Monk on Dec 16, 2011 at 18:04 UTC |