Hi Josef,

> I'd like to access a Perl-variable (a scalar) from within an XS. I do
> accept that the scalar may not (yet) exists, so I'd cater for that:
>
> How do I do that:
> - find out if a scalar exists
> - access the contents of the scalar.

If you know the name of a scalar variable, you can get a pointer to its SV by using the following:

    SV*  perl_get_sv("package::varname", FALSE);

This returns NULL if the variable does not exist.

If you want to know if this variable (or any other SV) is actually defined, you can call:

    SvOK(SV*)

http://www.sdsc.edu/~moreland/courses/IntroPerl/docs/manual/pod/perlguts.html

Hope this helps.

Cheers,
Olli

Reply via email to