creates a reference to %1, then why doesn't using something other than "1" correct the problem?while ($book_id = $sth->fetchrow_array()) { $booklist_1{$book_id} = 1; }
I mean, I just want to set the value of a hash element to one.
I love Perl - it's responsible for most of my personal income and written into most of my work by choice - so don't get me wrong on this next statement - but on a rare occasion Perl does really make me shake my head. It's not like I'm trying to invent calculus here. I just want to set the value of a hash element to 1 then recall the key. It shouldn't take strict and warnings and an in-depth discussion of special variables and references and most of the afternoon...this sort of thing is just ammunition for the anti-Perl crowd...ok, venting off...
By the way, using {} did make the script work correctly, with the sole exception that now $booklist_1{$book_id} equals 'HASH(0x8529f88)' - which is not a problem, per se, since I don't use it, but it seems a very messy result.
In reply to Re^6: Why is my code assigning the last-retrieved value to all elements in my hash?
by punch_card_don
in thread Why is my code assigning the last-retrieved value to all elements in my hash?
by punch_card_don
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |