in reply to Re: Add array ref to another array ref
in thread Add array ref to another array ref

Getting an error: Not a HASH reference at...

Replies are listed 'Best First'.
Re^3: Add array ref to another array ref
by holli (Abbot) on Jul 15, 2019 at 18:45 UTC
    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', };

        As shown by its data dumper output, $data_b is a reference to an array. The referenced array has a single element: a reference to a hash with four elements as shown.

        Assuming a successful operation to merge the contents of the hash referenced by $data_a, what would you then want the data dumper output of $data_b to look like?

        Update: The Perl Data Structures Cookbook (perldsc) may prove helpful now and in the future.


        Give a man a fish:  <%-{-{-{-<