HV* my_hash; AV* my_arr; int retVal = 0; char* my_argv[] = { "", cb->cbFunc.perlCbFunc.fileName }; // PERL interpreter creation my_perl = perl_alloc(); perl_construct( my_perl ); // PERL interpreter initiation perl_parse( my_perl, // The interpreter NULL, // XSINIT value - Should be NULL if no external modules are being used 2, // Number of entries in 'my_argv' my_argv, // PERL 'command line'. (char **)NULL); // ENV, not relevant for our usage // Run the PERL interpreter perl_run(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(1), 0 ); hv_store( my_hash, "bbb", 3, newSViv(2), 0 ); hv_store( my_hash, "cccccccccc", 10, newSViv(3), 0 ); hv_store( my_hash, "ddddddddd", 9, newSViv(4), 0 ); hv_store( my_hash, "eeeeeee", 7, newSViv(5), 0 ); hv_store( my_hash, "ffff", 4, newSViv(6), 0 ); hv_store( my_hash, "gggggg", 6, newSViv(7), 0 ); hv_store( my_hash, "hhhhhhh", 7, newSViv(8), 0 ); for ( int i = 0; i < 50; i++ ) { av_push( my_arr, newSViv((unsigned int)arr[i]) ); } // Store reference to parameters on the HASH hv_store( my_hash, "arr", 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 */ // Destruct PERL interpreter perl_destruct(my_perl); perl_free(my_perl);