in reply to Re^2: Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
in thread Why am I getting Can't use string (<string value>) as an ARRAY ref wile "strict refs" in use
Following #2 in Basic debugging checklist, I would recommend printing out the hash after every time you assign to a key or subkey of your %metrics hash. Because it's a complex structure, use Data::Dumper, as:
use Data::Dumper; ... # after some assignment like $metrics{$product}{$date} = $day; print STDERR Dumper \%metrics; $metrics{$product}{$date}{$hour}{$user} = $val; print STDERR Dumper \%metrics;
as a one liner, with hardcoded values, for the first assignment and print:
C:\usr\local\share\PassThru\perl>perl -MData::Dumper -le "$metrics{pro +duct}{today} = 'Wed'; print STDERR Dumper \%metrics" $VAR1 = { 'product' => { 'today' => 'Wed' } };
You might then notice that at the first print, the value of the 'today' key is a string, 'Wed', and not another { nested => hash }. With a string as the value of {today}, you cannot take another subkey (like {today}{12}), because strings don't have subkeys. I think you need to rethink your data structure. Maybe show us in the Data::Dumper-like notation printed above, what you do want your data to look like when you're done, and we can help you organize your data into that format.
|
|---|