I’ve got strict and warnings on, but it keeps complaining about the initialization of the following line:
$hash{$key} = ($row, [], [], [], '');
It warns for that single line:
"Useless use of private variable in void context"
"Useless use of anonymous list ([]) in void context" (3 times)
I am filling the data in later, but I want indexes 1, 2, 3 to be array references, and index 4 to be a string. I am accessing and filling the data like so:
$hash{$key}->[1]->[3] = 'Data';
$hash{$key}->[4] = $hash{$key}->[4] . 'More Data';
Obviously, I’m doing something wrong, but I’m not exactly sure how to make it right. (Also, I’m aware that that last line is redundant, could that also be summed up in a nicer way?)
Elements of a hash can only be scalars, so you have to change your assignment to use the anonymous array constructor instead of parens:
See perldsc for more information.
The line:
could be written:
And finally, unless you like them, the
->characters are implicit between subscript delimiters, so$hash{$key}->[1]->[3]means the same thing as$hash{$key}[1][3]