in reply to Undefined Array Reference

It took me a minute or three to figure out what the problem was. Correct me if I'm wrong: When you run the code, you get a "Can't use an undefined value as an ARRAY reference at line 21" error and you aren't sure why.

I can answer that part -- but what I can't answer is exactly what you're trying to do. The for loop is iterating from 0 to the maximum index in $ref_a. That reference is larger than what you'll find in $ref_b. Some simple print statement debugging will help show what I mean:

print "ref_a: ", $#$ref_a, "\nref_b: ", $#$ref_b, "\n"; for my $i (0..$#$ref_a) { print "Reading element $i\n"; push @{$ref_a->[$i]}, @{$ref_b->[$i]}; }

With some output:

ref_a: 5 ref_b: 2 Reading element 0 Reading element 1 Reading element 2 Reading element 3 Can't use an undefined value as an ARRAY reference at li +ne 23

To correct this problem, you can just choose the minimum of the two ref_a/b indices. But since I don't know what your goal is, I don't know if this will correct your issue.