in reply to Re^5: 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?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Why is my code assigning the last-retrieved value to all elements in my hash?
by kyle (Abbot) on Jul 09, 2008 at 21:45 UTC | |
by punch_card_don (Curate) on Jul 09, 2008 at 22:32 UTC | |
by kyle (Abbot) on Jul 10, 2008 at 03:30 UTC | |
by punch_card_don (Curate) on Jul 10, 2008 at 12:30 UTC | |
|
Re^7: Why is my code assigning the last-retrieved value to all elements in my hash?
by Anonymous Monk on Jul 10, 2008 at 03:44 UTC | |
|
Re^7: Why is my code assigning the last-retrieved value to all elements in my hash?
by punch_card_don (Curate) on Jul 09, 2008 at 21:02 UTC |