<?xml version="1.0" encoding="windows-1252"?>
<node id="123378" title="Re: XS routine returns an extra depth of array refs" created="2001-11-05 17:28:12" updated="2005-07-19 14:08:11">
<type id="11">
note</type>
<author id="41288">
jeroenes</author>
<data>
<field name="doctext">
Maybe the casting of entry to an SV does the trick. newRC_inc can also take an AV as input.
&lt;p&gt;
&lt;b&gt;Update&lt;/b&gt;: Tested the following... too lazy for XS, so 
Inline:
&lt;code&gt;
use Data::Dumper;
 
$ref = testRV( 'monks' );
 
print Dumper( $ref );
 
use Inline C =&gt; &lt;&lt;'END_OF_C'
 
SV* testRV(char* dirname){
 
  SV* record[2];
  AV *entry, *ret_val;
  SV* retarray;
  int i = 0;
 
 ret_val = newAV();
 
  while (i&lt;10) {
    record[0] = newSVpv(dirname, 0);
    record[1] = newSViv(i);
    entry = av_make(2, record);
    av_push(ret_val, newRV_inc( entry));
    i++;
  }
  retarray=newRV_noinc( ret_val);
  return retarray;
}
END_OF_C

#results in:
$VAR1 = [
          [
            'monks',
            '0'
          ],
          [
            'monks',
            1
          ],
          [
            'monks',
            2
          ],
...
&lt;/code&gt;
In other words, just a 2D array as you wanted. BTW,
Inline didn't complain about the AV* 's, but than, maybe
those warnings were suppressed?
&lt;p&gt;
So I think Fastolfe has pinpointed it, when he noticed
you exc'd the sub in array context...
&lt;p&gt;
If you really want to output arrays from C, you need
to push your items on the stack.
</field>
<field name="root_node">
123361</field>
<field name="parent_node">
123361</field>
</data>
</node>
