dTHX; // Returns NULL for my_perl :( // Call a PERL function dSP; /* Initialize stack pointer */ ENTER; /* Everything created after here */ SAVETMPS; /* ...is a temporary variable. */ PUSHMARK(SP); /* Remember the stack pointer */ XPUSHs(sv_2mortal(newSViv((unsigned int)cbCtx))); /* Push callback context onto stack */ my_hash = newHV(); my_arr = newAV(); hv_store( my_hash, "aaaaaa", 6, newSViv(42), 0 ); for ( int i = 0; i < 50; i++ ) { av_push( my_arr, newSViv((unsigned int)i) ); } // Store reference to parameters on the HASH hv_store( my_hash, "bbbbbb", 6, newRV((SV*)my_arr), 0 ); XPUSHs( sv_2mortal(newRV((SV*)my_hash)) ); //PUTBACK; /* Make local stack pointer global */ call_pv( funcName, G_SCALAR ); /* Call the function */ retVal = POPi; /* POP the return of the PERL function */ SPAGAIN; /* Refresh stack pointer */ PUTBACK; FREETMPS; /* free that return value */ LEAVE; /* ...and the XPUSHed "mortal" args */