Maybe I don't understand how modules work then, I thought they were
different from namespaces.  I thought that the existence of a .pm file
separate from the normal .pl files indicated a different processing
mechanism that the XSUB stuff hooked into.  Let me look into the module
code further, and see what it is doing, and maybe then I can frame the
question more correctly.

Thanks for pointing this out.

-----Original Message-----
From: Steven N. Hirsch [mailto:[EMAIL PROTECTED] 
Sent: February 14, 2005 1:32 PM
To: Southern, David
Cc: perl-xs@perl.org
Subject: Re: Extending an embedded Perl interpreter without a .pm file


On Mon, 14 Feb 2005, Southern, David wrote:

> Hi all, I've been searching for an answer to this questions for a 
> while now.  Perlmonks.org suggested this list, I wonder if anyone 
> might have some insight that the could share:
> 
> I have a C application that needs to execute fragments of Perl script 
> provided by the user.
> 
> I have successfully embedded the Perl interpreter, and it is working 
> great. The next step is to provide the ability for the user to make 
> calls into my C program to get certain information, take certain 
> actions, etc. I have written an extension using SWIG, and built that 
> into my program as well. After constructing my perl interpreter, with 
> the appropriate xs_init function that adds my DynTrans as a static 
> XSUB, I immediately use:
> 
>     eval_pv("use DynTrans;", FALSE);
> 
> To get my custom functions into the perl interpreter's namespace. This

> all works correctly, and I can call into my C program from the Perl 
> script.
> 
> So, the problem: In order for this to work, I have to have DynTrans.pm

> in the directory where I run my application. I want to remove this 
> requirement, I want the entire application to be completely 
> self-contained. I have gone so far as to modify my code like this:
> 
>     perl_setup_module();
>     eval_pv("use DynTrans;", FALSE);
>     perl_cleanup_module();
> 
> 
> The perl_setup_module creates the DynTrans.pm file, and the 
> perl_cleanup_module deletes it, and this also works. However I don't 
> like the fact of needing to drop a temporary file on the user's 
> filesystem.
> 
> So, the question: Is there a way that I can make XSUBs availiable to 
> my perl interpreter without having to have the .pm file around at all?

> I tried building the entire .pm file into my application with a series

> of
> eval_pv() for every line, but of course that didn't work. 
> 
> What I would really like is a programatic interface into whatever the 
> use DynTrans; perl stuff does. I have read and re-read perlembed, 
> perlxs, perlguts, perlapi, perlcall, several perl books, forums, 
> SuperSearch, etc. and I cannot find a way to do this.

A module is just a namespace in Perl.  If you want to define functions
in 
that namespace, do so explicitly.  Having said that, I'm not 100% sure 
what you are trying to accomplish...

Can you reword your explanation?

Steve


_____________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.

_____________________________________________________________________
This email message, including any attachments, may contain confidential and 
proprietary information for the sole use of the intended recipient.  If you are 
not the intended recipient, you are hereby notified that any use, copying or 
dissemination of this message is strictly prohibited.  If you received this 
message in error, please notify Brooks Automation, Inc. immediately by reply 
email or by calling Brooks US Headquarters at +1 978-262-2400. Then delete this 
message from your system, without making any copy or distribution.  Thank you.

Reply via email to