in reply to Re: Array_ref into Array_ref Help.
in thread Array_ref into Array_ref Help.

This is almost how I would like to have it, but I need here is, lets say the end result would be like:
a b c j k l d e f m n o g h i p q r

Because from the data base the first element of the first array_ref is relative to first element of the second array_ref.

Replies are listed 'Best First'.
Re^3: Array_ref into Array_ref Help.
by kennethk (Abbot) on Apr 22, 2009 at 17:49 UTC
    Do you mean you want to assemble the arrays into multidimensional structures? You should probably read up on arrays of arrays in perllol. The short answer is you could do it using

    my @AoA = ($array_ref, $array_ref_b);

Re^3: Array_ref into Array_ref Help.
by lostjimmy (Chaplain) on Apr 22, 2009 at 17:56 UTC

    What have you tried?

    my $ref_a = [ [ qw/a b c/ ], [ qw/d e f/ ], [ qw/g h i/ ], ]; my $ref_b = [ [ qw/j k l/ ], [ qw/m n o/ ], [ qw/p q r/ ], ]; for my $i (0..$#$ref_a) { push @{$ref_a->[$i]}, @{$ref_b->[$i]}; }
      That would work, one question to you would be:
      my $ref_a = [ [ qw/a b c/ ], [ qw/d e f/ ], [ qw/g h i/ ], [ qw/x y z/ ], [ qw/3 4 5/ ], [ qw/6 7 9/ ], ]; my $ref_b = [ [ qw/j k l/ ], [ qw/m n o/ ], [ qw/p q r/ ], ]; for my $i (0..$#$ref_a) { push @{$ref_a->[$i]}, @{$ref_b->[$i]}; }

      How could I assign maybe a empty value in order not get an error, if the results from one of the array_ref will be like the sample code here.
        I wouldn't be too upset if you tried out this one on your own...