http://www.perlmonks.org?node_id=696522


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

Use strict and warnings!!!

use Data::Dumper; my %booklist_l; $booklist_l{ 'foo' } = 1; $booklist_l{ 'bar' } = 1; $booklist_l{ 'foo' }{ 'update_id' } = 'update_id 1'; $booklist_l{ 'foo' }{ 'title' } = 'title 1'; $booklist_l{ 'bar' }{ 'update_id' } = 'update_id 2'; $booklist_l{ 'bar' }{ 'title' } = 'title 2'; print Dumper \%booklist_l; print Dumper \%1; __END__ $VAR1 = { 'bar' => 1, 'foo' => 1 }; $VAR1 = { 'update_id' => 'update_id 2', 'title' => 'title 2' };

That number '1' you put into every entry is being treated as a symbolic reference to the variable %1.