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,
http://search.cpan.org/~rgarcia/perl-5.10.0/lib/ExtUtils/Embed.pm).
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?
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
line.
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.
#!/usr/bin/perl
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";