in reply to Trying to print the contents of a hash, but getting a reference.
With warnings turned on your program yeilds warning:
for lineReference found where even-sized list expected at ...
And with use diagnostics you could get even more detailed explanation of problem:c={A=>'0',B=>'0',C=>'0',D=>'0'};
So conclusion is: use strict warnings and diagnostics or die.Reference found where even-sized list expected (W misc) You gave a single reference where Perl was expecting a list with an even number of elements (for assignment to a hash). This usually means that you used the anon hash constructor when you meant to use parens. In any case, a hash requires key/value pairs. %hash = { one => 1, two => 2, }; # WRONG %hash = [ qw/ an anon array / ]; # WRONG %hash = ( one => 1, two => 2, ); # right %hash = qw( one 1 two 2 ); # also fine
|
|---|