PerlStream << C++ and Perl

August 1st, 2009 Leave a comment Go to comments

This article was originally written in 2005.

Integration of Perl 5 into C++

Note:Except for short text processing scripts, for which Perl is still the best tool, I no longer recommend integrating Perl into large software systems. Its notorious write-only qualities almost guarantee that to do so can endanger the project. For such uses Python or Lua are often better choices.

PerlStream now has its own website

Embedding a Perl interpreter into a C++ program can be a powerful strategy – especially when existing C++ code required advanced text handling capabilities – something that native C++ code does not excel at. Nonetheless, the C API exposed by the Perl interpreter, documented in perlapi and perlembed is not for the faint hearted – and isn’t conducive to rapidly embedding some Perl code into a C++ program.

The January 2002 edition of the C/C++ User’s Journal (CUJ) contained an article by Robert Y. Seward called A stream class for calling Perl from C++, describing the implementation of a stream interface to an underlying instance of the Perl interpreter, allowing Perl source code to be streamed directly to the Perl interpreter and executed. The code from CUJ was subsequently modified by Will Nolan to fix minor bugs and make it work on his Sun Forte compiler.

Since using a modified version of the magazine code for professional purposes, I’ve since undertaken a complete re-write of PerlStream, which is now available from Tigris.

  1. No comments yet.
  1. No trackbacks yet.