in reply to Add array ref to another array ref

Just overwrite the original hash with a merge of both hashes.
$data_a = { %$data_a, %$data_b };


holli

You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re^2: Add array ref to another array ref
by Anonymous Monk on Jul 15, 2019 at 18:36 UTC
    Getting an error: Not a HASH reference at...
      Then your data is different from what you tell us:
      D:\ENV>perl -MData::Dumper -e "$ha = { a => 'A' }; $hb = { b => 'B' }; + $m = { %$ha, %$hb }; print Dumper( $m );" $VAR1 = { 'b' => 'B', 'a' => 'A' };


      holli

      You can lead your users to water, but alas, you cannot drown them.
        I did a data dumper on $data_b and got this:
        $VAR1 = [ { 'house' => 'main', 'number' => '0123', 'area' => 'north', 'code' => 'zip', }; ]

        And on $data_a was this:
        $VAR1 = { 'fullname' => 'Ms Mary Lou', 'first' => 'Mary', 'last' => 'Lou', };