Hashes start off empty. But if you put your code into a subroutine and call it twice, the second time around it will still be populated from the first.
Incidentally I'm willing to bet, sight unseen, that the actual code in the cookbook got this right. :-P
Cheers,
Ben