in reply to Re^8: 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?

Unless there's some reason for wanting '1', I'd put the actual book ID in the 'book_id' slot of that hash.

while (($book_id) = $sth->fetchrow_array()) { $booklist_1{$book_id}{'book_id'} = $book_id; }

Unless you have a book ID of '0', it will still be true in boolean tests, and it will be less confusing to future programmers.

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

Replies are listed 'Best First'.
Re^10: Why is my code assigning the last-retrieved value to all elements in my hash?
by punch_card_don (Curate) on Jul 10, 2008 at 12:30 UTC
    Getting too squished on my screen - see bottom of thread for my conclusion in the light of the next day....




    Time flies like an arrow. Fruit flies like a banana.