in reply to Merge hashes in specific format

Hello ovedpo15,

Just a quick review: you are overwriting because of: %{$href} = %{JSON::PP->new->decode($json_data)};

Ie: as you noted, at each file iteration you are reassigning the content of $haref with new data.

You must instead do something like:

# untested foreach my $key ( keys %{JSON::PP->new->decode($json_data)} ){ # some collision check? if ( exists $$href{ $key }){ warn "$key already exists! was [$$href{ $key }] and will be [${JSO +N::PP->new->decode($json_data)}{$key}]\n"; } # assign a new key value pair $$href{$key} = ${JSON::PP->new->decode($json_data)}{$key}; }

Try, before dealing with your JSONS, with a bounch of test hashes until you get it working.

Also I'd avoid subs named encode and decode because of the risk of collision and for readability: if I see encode when using a JSON module I think about the module method ;)

HtH

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.