Hello out there ... anybody with REAL perl expertise? well I hope b/c I have
a question:

i'm trying to embed perl into a C++ application, and this app happens to be
a multithreaded one with several instances of an object that need to embed
perl scripts. i NEED to have several interpreters (one will do but I need a
lot of tricks and may be VERY expensive at runtime). i am trying to compile
a sample code from the perlembed man page that shows a 2-interpreter C
program, but it does not work as expected. I AM COMPILING
WITH -DMULTIPLICITY but no luck. anybody knows what the problem is?
basically, the script that gets parsed last with perl_parse (...) is the one
that produces the output for all instances. here is kind of what i have:

class MyClass
{
  PerlInterpreter *myPerl;
public:
  MyClass (char *script);
  ~MyClass ();
};

MyClass::MyClass (char *name)
{
  char *argv[] = {NULL, name, NULL};
  myPerl = perl_alloc ();
  perl_construct (myPerl);
  perl_parse (myPerl, xs_init, 3, argv, NULL);
  perl_run (myPerl);
}

MyClass::~MyClass ()
{
  perl_destruct (myPerl);
  perl_free (myPerl);
}

int main ()
{
  MyClass o1 ("my_perl_script_1");
  MyClass o2 ("my_perl_script_2");
}

where my_perl_script_1 is:
#!/usr/bin/perl
print "HELLO FROM 1";

and my_perl_script_2 is:
#!/usr/bin/perl
print "HELLO FROM 2";

After compiling with -DMULTIPLICTY, the output is:
HELLO FROM 2
HELLO FROM 2

as instead of
HELLO FROM 1
HELLO FROM 2

anybody knows what I could be missing?

---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to