in reply to What causes HASH to print?

OK, this is a "what's wrong with my code" question, which is probably an inappropriate use of this site

Not at all. It looks like you've made a effort to cut the problem down to the minimum amount of code. That's exactly the kind of problem that we're happy to help with.

You've been given the correct answer by a few people, but I thought you might be interested in a couple of other clues that you could have got for yourself.

If you had "use warnings" in your code, then you would have seen this error message:

Reference found where even-sized list expected

Which is true (as you now know from seeing what the problem is) but perhaps not as clear as it could have been. To get more help when tracking down a weird error like that, you can add "use diagnostics" to your code and Perl will then give you a complete description of the problem. In this case, it would have said the following:

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

So, in this case, I think that Perl would have given you exactly the help you were looking for to solve your problem.