Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Calling a C++ subroutine from Perlby ibm1620 (Hermit) |
on Mar 19, 2019 at 00:36 UTC ( [id://1231411]=perlquestion: print w/replies, xml ) | Need Help?? |
ibm1620 has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
Our company obtained a C++ source code license for Metaphone3 and I want to test it using Perl as a driver. I'm wondering what my options are. In the past, when I needed to call a complex C subroutine from Perl, I've written a standalone C++ program that accepted command-line parameters, called the subroutine, and wrote the output to STDOUT, and then "called" it using qx//. That's certainly still a possibility, but on the offchance that the forking and IPC would pose a performance hit (I'm going to test 100M's of strings), I wondered if XS was a practical possibility. I have never written an XS module, and it looks daunting, but I thought there might be some XS stub code out there that I could easily tweak so that a Perl program could call one subroutine, passing in one string and getting two strings back; end of story. Any thoughts on the subject? Other approaches? (Metaphone3 is also available in Perl, but unfortunately that's a separate license.)
Back to
Seekers of Perl Wisdom
|
|