I'm using the following code to process lines in the $discovered array, and create a number of hashed pairs in the same array row. The code works well.
until ($discovered[$i] eq ""){ ($key, $value) = split /:\s*/, $discovered[$i]; $arrayAoH[$j]{$key} = $value; $i++; }
But, when I enabled 'use strict' in my code, I get the following error when the line containing '$arrayAoH[$j]{$key} = $value;' is executed:
"Can't use string ("") as a HASH ref while "strict refs" in use at xxx.pl"
I've pored over the examples in 'Programming Perl', and have Google'd a bit. But I just don't understand why that line is wrong, and what I should do to fix it.
I tried using the following line in place of the offending line:
$arrayAoH[$j] = { $key => $value };
but it creates an array row with only a single has (whatever the last has processed was).
Thoughts, please!
Thanks tl
20050623 Edit by ysth: code tags
In reply to Array of hashes reference problem by tlemons
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |