G'day Sami_R,

Here's one way to do it. I've minimised your data for demonstration purposes.

$ perl -e ' use strict; use warnings; use Data::Dumper; my $VAR1 = { Total => { month1 => 0, month2 => 0 }, Tom => { month1 => 17, month2 => 1 }, }; my $VAR2 = [ { Total => { week1 => 0, week2 => 0 }, Harry => { week1 => 0, week2 => 5 }, } ]; my %joined_FS = ( Total => { %{delete $VAR1->{Total}}, %{delete $VAR2->[0]{Total}}, }, %$VAR1, %{$VAR2->[0]} ); print Dumper(\%joined_FS); ' $VAR1 = { 'Tom' => { 'month1' => 17, 'month2' => 1 }, 'Total' => { 'month2' => 0, 'month1' => 0, 'week2' => 0, 'week1' => 0 }, 'Harry' => { 'week2' => 5, 'week1' => 0 } };

— Ken


In reply to Re: Error: when joining two hashes by kcott
in thread Error: when joining two hashes by Sami_R

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.