in reply to Re: Why is my code assigning the last-retrieved value to all elements in my hash?
in thread Why is my code assigning the last-retrieved value to all elements in my hash?

With all due respect to Kyle, I don't believe it has anything at all to do with using "1".

I think you're still misunderstanding what kyle said.

Indeed, the problem isn't that you were using "1" specifically -- but kyle didn't say that. He said that the problem is that you were using a value that wasn't a hashref and then later trying to treat it as one (and the value you were using that wasn't a hashref happened to be "1").

When I extend it to two dimensions, it becomes a hash of hashes and the first dimension's keys must become references to the second dimenion hashes. So now keys %booklist_1 is a bunch of hash references, and no longer the bunch of book_ids I set them to originally.

No. The keys don't change. I believe the keys can never be anything other than strings. It's the values that become hash references in a hash of hashes.

I commend Data::Dumper to you -- it really is a good way of visualising what's going on underneath your data structures. And good luck -- I think even the most wizened master here will agree that the easiest thing to do with Perl data structures is to mess them up. :)

  • Comment on Re^2: Why is my code assigning the last-retrieved value to all elements in my hash?