Can't use string ("XXX") as a HASH ref while
"strict refs" in use at test.pl line 20, <LOG> line 1.Here is the code I am looking at.
use strict; use warnings; my (@unix_data,@nt_data); open LOG, "nt_data.txt" or die "Cannot open unix_data.txt $!"; while (<LOG>) { chomp; my $hashname; my @keysandvalues; my @field = split /,/, $_; foreach (@field) { my ($key, $value) = split /\s*=\s*/, $_; if ($key =~ /^(LocalTran)(\w*)(Number)$/) { $hashname=$value; } push @keysandvalues, $key; push @keysandvalues, $value; } %{$hashname}=@keysandvalues; push @nt_data,\%{$hashname}; } foreach (@nt_data) { my $key; print "-+" x 90 . "\n"; foreach $key (keys %{$_}) {print "$key => ${$_}{$key}\n";} }
Of course it works properly when I set 'no strict "refs";' in the block, but I don't want to do that, I want to find out why I am running into this problem. I am currently reading through the Camel Book to find a solution, but thought I'd post it here as well to see if I can't learn something. Thanks in advance. I'm sure the answer is quite simple but I can't quite get my head around it right now.
In reply to Problem with strict "refs" by nimdokk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |