satzbu has asked for the wisdom of the Perl Monks concerning the following question:
please help me to debug this error i have an error report like missing $ on loop at hashreplace.pl this is my code
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %xhash = ('a' => { 'b' => { 'e' => 'E', 'c' => 'C', 'content' => 'B ' }, 'content' => 'A ', 'd' => 'D' }); my $key = keys(%xhash); print $key; my %c_hash=('a' => { 'addval' => { 'b' => { 'addval' => { 'e' => { 'addv +al' => {}, 'repv +al' => '5' }, 'c' => { 'addv +al' => {}, 'repv +al' => '3' } }, 'repval' => '2' }, 'd' => { 'addval' => {}, 'repval' => '4' } }, 'repval' => '1' }); print $c_hash{'a'}{'repval'}; foreach keys($xhash){ keys(%xhash)=$c_hash{'$key'}{'repval'}; print Dumper $xhash;}
i want to replace xhash keys against c_hash values i mean this output only i want
%xhash = ('1' => { '2' => { '5' => 'E', '3' => 'C', 'content' => 'B ' }, 'content' => 'A ', '4' => 'D' });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: for loop error
by roboticus (Chancellor) on Apr 13, 2010 at 11:32 UTC | |
|
Re: for loop error
by almut (Canon) on Apr 13, 2010 at 12:54 UTC | |
by satzbu (Acolyte) on Apr 21, 2010 at 03:49 UTC | |
|
Re: for loop error
by apl (Monsignor) on Apr 13, 2010 at 11:23 UTC | |
by almut (Canon) on Apr 13, 2010 at 11:37 UTC |