It's quite hard to figure it out without any input data, because it means that we can't run a copy of the script on our own machines! It is generally pretty useful if your sample code is self-contained!
That said, I think your problem stems from doing this kind of thing:
my $branch_ref = $branches{$1};
%tmp_branch = %$branch_ref;
The second line does a shallow copy of the hash, so %tmp_branch
is no longer the same hash as the one referenced by $branches{$1}
. When you add data to the %tmp_branch
hash, you are not adding data to the $branches{$1}
hash.
@tmp_array
suffers similarly.