Hi, suppose I want to trigger external Perl subroutines but don't want to pass the argument via the stack but rather by setting $_. Is the following correct?
void call_coderef (SV *coderef, char *path) { SV *src; dSP; SAVESPTR(DEFSV); ENTER; SAVETMPS; PUSHMARK(SP); DEFSV = sv_2mortal(newSVpvn(path, strlen(path))); PUTBACK; (void) call_sv(coderef, G_DISCARD); FREETMPS; LEAVE; } Some non-thorough empirical tests suggest that it is neither leaking memory nor is the old value of $_ destroyed: $_ = "bla"; code_that_calls_above_coderef(); ok($_ eq "bla"); # $_ has been restored apparently But surely, it can't be that simple, can it? Tassilo -- $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval