views:

687

answers:

3

I have a C program with an embedded Perl interpreter. I want to be able to precompile some Perl code from within the program. How do I do that?

Rationale (if anyone is interested) is to be able to compile it once, store the parse tree, and execute many times (as long as the compiled code does not change).

Thanks! Madhu

PS: I am using Perl-5.8, though it would be good to know if Perl-6.0 makes this easier in any way.

+10  A: 

This is the default behavior when you embed the Perl interpreter in a C program. After you've run perl_parse() to parse the Perl program, you can use perl_run() and call_argv() over and over with the same parsed Perl program.

Glomek
A: 

In reference to Perl 6, it's not complete. But 5.10.0 might have some bug fixes over 5.8.

Schwern
A: 

You can use perlcc to create executable or C sources.

To compile your C code, you would need to use perl's library (could be -lperl or -llibperl).

Osama ALASSIRY
If all you want is an executable binary, use PAR to do that. http://search.cpan.org/perldoc?pp
Schwern