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' });
In reply to for loop error by satzbu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |