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

Hello everyone,
just would like to know how to call perl script (module) from C/C++ ?

am not looking for any readymade module (which has licensing issues :o) ) 
but a very rudimentary way of calling perl modules from C, i can write wrappers on top of it.

cheers,
M 

Replies are listed 'Best First'.
Re: calling perl from C/C++
by ccn (Vicar) on Dec 22, 2008 at 11:40 UTC
    perldoc perlembed - how to embed perl in your C program
Re: calling perl from C/C++
by Bloodnok (Vicar) on Dec 22, 2008 at 12:58 UTC
    If it is truly a script you wish to call, then use the system or fork() & exec() functions in, IIRC, stdlib.

    A user level that continues to overstate my experience :-))
Re: calling perl from C/C++
by Perlbotics (Archbishop) on Dec 22, 2008 at 14:20 UTC

    You could use system (with STDERR/STDOUT redirected) or popen to communicate with an external perl process.

    The system() approach is more batch-like. You can later open (or tail) the output from the redirected streams. popen() would allow you to interact with the external perl process (reading/writing) while it is executed.

    Further issues to handle: buffering, timeouts, return-codes, security, permissions, ...
    Something along this demo: