Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^13: Merge hashes in specific format

by tybalt89 (Monsignor)
on Jan 13, 2019 at 00:41 UTC ( #1228447=note: print w/replies, xml ) Need Help??


in reply to Re^12: Merge hashes in specific format
in thread Merge hashes in specific format

That's not a sub.

Posting incomplete code will cause an incomplete an

Replies are listed 'Best First'.
Re^14: Merge hashes in specific format
by ovedpo15 (Pilgrim) on Jan 13, 2019 at 00:46 UTC
    I'm sorry. here you go:
    my %final_href; merge_jsons(".data.json",\@dirs,\%final_href); sub merge_jsons { my ($name,$dirs,$final_href) = @_; my %data; foreach my $dir (@{$dirs}) { decode($dir."/".$name,%data); # will change name my $final_href = ( data => { ( %{$final_href->{data} },%{ $data{data} } ) }, total => do { my %total; for my $href ( $final_href->{total}, $data{total} ) { $total{$_} += $href->{total}{$_} for keys %{ $href->{to +tal} }; } \%total; } ); } }
Re^14: Merge hashes in specific format
by LanX (Sage) on Jan 13, 2019 at 00:48 UTC
    > Posting incomplete code will cause an incomplete an

    brilliant! xD

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228447]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2023-03-22 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (60 votes). Check out past polls.

    Notices?