http://www.perlmonks.org?node_id=11104862

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi there Monks!

I need to insert the @$data2 value into the @$data1. The code I have only updates the first element in the @$data1:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $data1 = [ { 'NAME' => 'PAUL DY', 'DATE' => '2009-05-05', 'NUMBER' => '00001', }, { 'NAME' => 'ANTHONY RD', 'DATE' => '2012-01-07', 'NUMBER' => '00003', }, { 'NAME' => 'RUTH RD', 'DATE' => '2018-01-07', 'NUMBER' => '00023', }, ]; my $data2 = [ { 'CODE' => 'X11', } ]; @$data1= ({map { %$_ } (@$data1, @$data2)}); print Dumper $data1;

Thanks for helping!