On Mon, 11 Jun 2001, Ryan Sadler wrote:
> I thought I would toss this one out to the perl-bowels experts. Is there
> a safe way to create another instance of a perl interpreter while the
> current interpreter is running. I think this is the equivalent of running
> perl_run(perl_interp1); from within perl_run(perl_interp2); The
> version of perl that I'm running is compiled for multiplicity. The
> changes that would be necessary within perl to make it work this way
> would not be pretty. Does anyone else have an idea on how to do this?
> I don't plan on hacking perl, it will have to be tclperl that will change.
> For those not familiar with tclperl, it goes through a similar startup
> sequence as in perlmain.c:
> my_perl = perl_alloc();
> perl_construct(my_perl);
> perl_parse(...);
> perl_run(my_perl);
>
> Perhaps I need to instantiate the two interpreters I'd like to use before
> running them. From the info I can dig up about multiplicity "you can have
> completely separate and independent interpreters inside the same process"
>
> I've read perlembed, but the example in there is too simple. I don't
> think perl is meant to do this.
>
> Since this is probably an issue with multiplicity, perhaps I'll take this
> to a perl newsgroup. Stabs in the dark welcome.
In early March I built a hyper-version of Inline::Python that exposes Perl
to Python, which sounds like what you're doing with Tcl. You might be
interested in looking at that:
http://ttul.org/~nwatkiss/CPAN/Inline-Python-0.20-TRIAL1.tar.gz
I use the same interpreter, so that data can be shared between the two. As
far as running perl_run(perl2) from inside perl_run(perl1), there should
be no problem with that at all. Just don't call perl2 my_perl.
For another take on it, check out Sarathy's Perl.pm module on CPAN. It
creates Perl interpreters from Perl, I believe, using the same methods
we've talked about.
Later,
Neil