Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Calling a C++ subroutine from Perl

by bliako (Monsignor)
on Mar 19, 2019 at 18:26 UTC ( [id://1231449]=note: print w/replies, xml ) Need Help??


in reply to Calling a C++ subroutine from Perl

I will mention the possibility to embed a perl interpreter inside a C program. See perlembed. It has benefits if your main logic is in C/C++ and you just want a quick regex engine or accessing a database). For example: in perl embeded engine access database, retrieve data, filter data, use regex and other easy-peasy perl string mamipulations, then pass result back to C for metaphone. That gives you additional freedom depending where your main program logic is.

There is a bigger prize though: parallelism. Theoretically you can have many perl interpreters in same C program. And you may find the C++ threads model, option of shared memory etc., is better suited for your needs than Perl's.

I have not tried compiling a C++ program with perl embeded, only with C. The reason I am mentioning it is that it gives you one more way to experiment. I can give more details if you want to proceed. I must say that you may encounter a few hiccups in compiling and linking with perl's headers and library. But the major difficulty will be that the same compiler used in compiling your perl must also be used in compiling the perl-embedded C/C++ program. That means C++. Which theoretically should be OK but in practice it may complain about c++XYZ standard of the month forbidding this or that.

bw, bliako

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1231449]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-23 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found