in reply to Re: Combining two references
in thread Combining two references

What if you just want to merge these two arrays:

... my $data1 = [ { 'NAME' => 'PAUL DY', 'DATE' => '2009-05-05', 'NUMBER' => '00001', }, ]; my $data2 = [ { 'CAR1' => '1b', 'CAR2' => '2b', 'CAR3' => '3b', 'CAR4' => '3d', }, ]; ...

into:
my $data3 = [ { 'NAME' => 'PAUL DY', 'DATE' => '2009-05-05', 'NUMBER' => '00001', 'CAR1' => '1b', 'CAR2' => '2b', 'CAR3' => '3b', 'CAR4' => '3d', }, ];

Thanks!

Replies are listed 'Best First'.
Re^3: Combining two references
by CountZero (Bishop) on Jun 10, 2015 at 15:04 UTC
    Why don't you try and see what it does?

    I'll wait while you try. ......

    See, it "just worked". Ain't Perl nice?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      I know it works using the module:
      List::MoreUtils qw/zip natatime/;

      Can it be done without it?

      #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $data1 = [ { 'NAME' => 'PAUL DY', 'DATE' => '2009-05-05', 'NUMBER' => '00001', }, ]; my $data2 = [ { 'CAR1' => '1b', 'CAR2' => '2b', 'CAR3' => '3b', 'CAR4' => '3d', }, ]; my $new_data; push @{ $new_data }, $data1,$data2; print Dumper $new_data;

      And get this,
      I couldn't:
      my $data3 = [ { 'NAME' => 'PAUL DY', 'DATE' => '2009-05-05', 'NUMBER' => '00001', 'CAR1' => '1b', 'CAR2' => '2b', 'CAR3' => '3b', 'CAR4' => '3d', }, ];