Hi I have the following code snippet which should return an array. This doesn't seem to work. Could someone tell me what is wrong in this code? SV *retsv=NULL; AV *av; int i = 5; av = newAV(); retsv = newRV(sv_2mortal((SV*)av)); while(--i >= 0) { av_store(av, i, newSViv(i)); } ST(2)=sv_2mortal(retsv); When called from the script, the length is always returned as 1. But I am unable to see the contents. When @x and $z = $x[0] are printed, it shows nothing. If I replace ST(2)=sv_2mortal(retsv); with sv_setsv(ST(returnIndex),sv_2mortal(retsv)); then I get ARRAY(0x....) for @x and "01234" for $z = $x[0] from the script. Thanks Aby