http://qs321.pair.com?node_id=551236

sjfloat has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing C code that that calls perl. The perl code is in the form of a .pm that will be installed in the usual way. The approach I have taken is to call load_module something like:
load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("My::Module", 10), newSVnv(0.01));
I follow this by pushing the module name onto the stack and instantiating an object by calling call_method("new", G_SCALAR));

I then push the resulting object and some args onto the stack and invoke call_method on the method name. It seems to necessary to call perl_parse, so I do, passing in "/dev/null" as the file name.

char *theArgv[] = { "", "/dev/null" }; perl_parse(my_perl, xs_init, 2, theArgv, (char **) NULL);
All this actually seems to work pretty swell, but I've encountered one difficulty. Any diagnostics originating in the perl code, e.g. "warn"s, etc., give bogus file and line numbers presumably because, having been pulled in via the load_module call, the code was never parsed:

Bad data at /dev/null line 0

I'd like to use the load_module mechanism and yet have the perl interpretter informed of code, for diagnostic reference.

[I can post more code, if helpful. But the actual code is on an isolated host, inaccessible by network.]

Any ideas?