mak007 has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am encountering a very strange issue where hash keys are created by just being referenced in the condition statement of an if-statement. Dumper($hash_ref), returns the following:
$VAR1 = { 'block1' => { 'lib1' => { 'cell_1' => 1, 'cell_2' => 1, }, }, 'block2' => { 'lib1' => { 'cell_3' => 1, 'cell_4' => 1, }, }, };
After running the following code where $block="block3" & $libName = "lib1" :
if(!defined $hash_ref->{$block}->{$libName}) { print "This is a test\n"; }
Dumper($hash_ref), returns the following:
$VAR1 = { 'block1' => { 'lib1' => { 'cell_1' => 1, 'cell_2' => 1, }, }, 'block2' => { 'lib1' => { 'cell_3' => 1, 'cell_4' => 1, }, }, 'block3' => {}, };
Any ideas why this is happening. The same script used to work ok, but it suddently stopped working. I have tried different perl installations but the issue persists!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange Hash related bug, keys are created by themselves!
by marioroy (Prior) on Nov 03, 2016 at 17:46 UTC | |
|
Re: Strange Hash related bug, keys are created by themselves!
by BrowserUk (Patriarch) on Nov 03, 2016 at 17:38 UTC | |
by Anonymous Monk on Nov 03, 2016 at 19:04 UTC | |
by Laurent_R (Canon) on Nov 03, 2016 at 23:11 UTC | |
by BrowserUk (Patriarch) on Nov 03, 2016 at 20:21 UTC | |
|
Re: Strange Hash related bug, keys are created by themselves!
by davido (Cardinal) on Nov 03, 2016 at 23:24 UTC | |
|
Re: Strange Hash related bug, keys are created by themselves!
by hippo (Archbishop) on Nov 04, 2016 at 10:09 UTC | |
|
Re: Strange Hash related bug, keys are created by themselves!
by dsheroh (Monsignor) on Nov 04, 2016 at 07:56 UTC |