embeding perl in C++

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

It seem libperl can be used to embed perl in C++. But that was
developed long ago and is for C. I'm wondering if there are any new
and better library to embed perl in C++.


Re: embeding perl in C++

Peng Yu wrote:
Quoted text here. Click to load it

On the one hand, embedding *modern* Perl (5.10) is straight-
forward and easy if you know the pitfalls. On some projects,
I link the perl core to C++-programs, this works fine in Visual
Studio 6 up to Visual Studio 9 without any problems so far (using
the Activeperl distribution, others might work too). Under Linux,
the path to success is even simpler, just use the appropriate
Perl-Modules which support the embedding process (ExtUtils::Embed,

On the other hand, after the advent of the boost libraries
(e.g. Boost::Regex), there is (for me at least) dwindling
need to use this approach at all.

What do you want to use it for?



Re: embeding perl in C++

Quoted text here. Click to load it

I want to use it for processing text files. I feel that for certain
applications in text processing, writing perl code is much faster than
writing the equivalent C++ code. For example, I have a text file, who
is sorted based on the second to last column (called column X for
short), but there is no blank lines. Let's call the lines of the same
column X as a group. I would like to append the first line of each
group to the end of it and then add a blank line after the appended

This can be done in just a few line of perl code (as follows), but it
would need much longer C++ code. In terms of program productivity,
using perl shall be much better than using C++ in text processing
applications. Using Boost::Regex still requires writing more code.
Therefore, I'm looking for embedding perl in C++.

perlembed is for C. Is any other packages that for embedding perl in C+
+? Although C is a subset of C++, my impression is that a package
design for C++ would better than a package designed for C in C++. For
example, boost.python is developed even there is a package to embed C
in python.


while (<>)
  @data = split;
  if (!defined($last_column)) {
    $first_line = $_;
    $last_column = $data[$#data - 1];
  if ($data[$#data - 1] != $last_column) {
    $last_column = $data[$#data - 1];
    print "$first_line\n";
    $first_line = $_;
  print $_;
print "$first_line\n";

Re: embeding perl in C++

On Wed, 02 Jul 2008 23:00:58 -0700, Peng Yu wrote:

Quoted text here. Click to load it


Actually I'm working on just that! It's similar to boost.python, but in
an earlier stage. Mail me if you're interested.



Re: embeding perl in C++

Leon Timmermans wrote:
Quoted text here. Click to load it


Quoted text here. Click to load it

I hope not ;-)

Quoted text here. Click to load it

Boost_Python is, IIRC, for exposing C++ functions
to a Python program and not for using Python within
a C++ program. It does  what SWIG does - but hides that
process it behind an interface.

(I don't get it - what this is all about and what this
one has to do with Boost, but YMMV ...)



Site Timeline