- To: slug@xxxxxxxxxxx
- Subject: [SLUG] segfault setting perl variables in C code
- From: David Fitch <davidf@xxxxxxxxxxxxxx>
- Date: 07 Apr 2003 17:45:25 +0930
ok perl gurus:
I have a C program that starts a perl interpreter and runs
a perl script using perl_alloc, construct, parse and finally
perl_run. I'm trying to set a perl variable in the C code
before starting the perl script. This variable is then
accessible from the perl script. That's the idea anyway.
I reckon it should be possible using something like either
of these (from reading 'man perlguts'):
SV *sv = newSVpv("MYID", 4);
or:
SV *sv = get_sv("MYID", TRUE|GV_ADDMULTI);
sv_setpv(sv, 42);
SvPOK_on(sv);
But either way just segfaults on the first call.
Do I have the wrong end of the stick about how this is supposed
to work? Any ideas?
thanks,
Dave.