In the January 2002 issue of the C/C++ Users Journal there was an article with source for a streaming class to execute Perl code from C++. When I initially attempted to use it I found some problems. Probably most of which were caused by the Sun Forte 6.0 C++ compiler.

Anyway, I fiddled around with it and got it working, and added a class to instantiate the interpreter. I think the author must have been using a pre-5.6 version of Perl, but my experience in calling Perl from C++ is limited to my attempts to get this working, so I really don't know. However, the class is pretty neat.

You can download it here. To build it, you have to link in libperl and provide include paths for Perl headers and libperl to your compiler. I recommend building a library using everything except the test program. Then build the test program separately and link in the library.