Problems with perlapi and PL_sv_undef

From: Mladen Georgiev (dziftar_at_yahoo.com)
Date: 04/23/04


Date: 23 Apr 2004 00:32:52 -0700

Hello!
I'm trying to call a perl subroutine from a C++ program via perlapi.
Here is the perl code

sub SaveDocuments {
        my ( $files, @questions ) = @_;
        ...
}

In that subroutine $files must be array reference.
If I push &PL_sv_undef value for $files (there are no files)

XPUSHs( &PL_sv_undef );

$files is assigned the first element of @questions array (the rest of
parameters array).
Hereis how I fill @questions array in C++ code:

if ( Document->Questions != NULL ) {
        for ( int i=0; i < Document->Questions->Count; i++ )
        {
                XPUSHs(sv_2mortal(newSVpv(Document->Questions[i],strlen(
Document->Questions[i] ) )));
        }
}

Where am I wrong?
Thanks in advance!

Best regards,
Mladen