Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Add array ref to another array ref

by holli (Abbot)
on Jul 15, 2019 at 18:23 UTC ( [id://11102878]=note: print w/replies, xml ) Need Help??


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', };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found