Hi Everyone
I am learning Inline:C for perl and I just wanted to try something
like this :
use Inline C => DATA =>;
# Initialize variables
$num = 10;
@numarr = ();
# Given an array reference, this subroutine assigns an array reference
# to each element of the given array - making a 2-dimensional array,
# basically ...
sub arr_fill {
my($tmparr) = @_;
my @randarr;
for($i=0;$i<$num;$i++)
{
$randarr = [1,2,3,4];
${$tmparr}[$i] = $randarr;
}
}
# Call the subroutine
&arr_fill([EMAIL PROTECTED]);
# A C function which I want to use
# to add 1 to each element of the above
# 2-dimensional array
add_one([EMAIL PROTECTED]);
__DATA__
__C__
void add_one(SV* arr)
{
int i;
AV* array;
SV* array2, tmp2;
SV** tmp;
if (!SvROK(arr) || SvTYPE(SvRV(arr)) != SVt_PVAV)
croak("Dead in the water. Bad reference passed.\n");
# get the pointer to the original array
array = SvRV(arr);
???????????????????? *
}
* Here is where I am stumped ... don't know what to do next, I have to
get the second array reference out from this array reference right?
How do I do that?
-------------------------------
Any help would be much appreciated?
Thanks !!
Nitin Madnani
University of Maryland, College Park