7

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.

1
  • wrt your rationale, are you embedding Perl just to store the parse tree and thus decrease startup time? Or does the C program do something else? If it's just for startup time, there's other ways to do that. Commented Nov 6, 2008 at 6:31

3 Answers 3

12

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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).

1 Comment

If all you want is an executable binary, use PAR to do that. search.cpan.org/perldoc?pp
0

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

Comments