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?


In reply to Perl. Problem with HASH value by breeze

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.