in reply to Hashes... Light switch isn't coming on

replace

%HoH = {$primary}{$secondary} => $tertiary); ¹

with

 $HoH{$primary}{$secondary} = $tertiary;

EDIT:

But what I actually get is

$VAR1 = { 'bar' => 'p2', 'itemb' => undef };

sure, you're redefining the complete Hash in the deepest loop, and these are the three values of the last iteration. (plus undef because hashes are always even)

Cheers Rolf

¹) which has a syntax error at ), please only post code you really tried.