note
Nkuvu
<p>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 scriptname.pl line 21" error and you aren't sure why.</p>
<p>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 <c>$ref_a</c>. That reference is larger than what you'll find in <c>$ref_b</c>. Some simple print statement debugging will help show what I mean:<br>
<c>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]};
}</c></p>
<p>With some output:<br>
<c>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 scriptname.pl line 23</c></p>
<p>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.</p>
759433
759433