I must try to use Perl, but have to contact another application I authored. I've an interface library which i authored in C++, also it consists of the socket communications and interface protocol to createOrget parameters during my application.

I must use Perl with Apache for everyone up webpages for setting up my application. I have to understand how to get Perl to speak to my interface library.

Oh The almighty, if you're a new comer to Perl. you don't want to become searching at XS (I'm not a new comer to Perl and that i don't want to check out XS). See Inline::C or Inline::CPP for any much gentler summary of calling C and C++ from Perl. Drilling much deeper in to the XS interface should simply be necessary if you wish to start passing or coming back complicated data structures around (and perhaps not really then).

use Inline C => Config => LIBS => '-L/<yourlibpath> -l<yourlib>';

$x = my_library_function_that_returns_an_int_or_double($integer_arg,$string_arg);

It appears like you need to contact a C library from Perl. You will want to go through perldoc perlxs and perldoc perlxstut for additional concerning the XS interface. If you wish to perform the reverse (call Perl from C), also go through perldoc perlguts and perldoc perlembed.

Whenever you encounter specific problems, give SO another holler and someone can surely assist you. :)

Should you chose to not go the inline-C route, Perl has built-in support for electrical sockets, An excellent tutorial on doing IPC, along with a couple of objects to assist with electrical sockets generally (plus, google will give you a number of other lessons on using perl electrical sockets). If you are able/prepared to re-implement the electrical sockets communication part, you might not even require the C/C++.

You have to produce a module for you personally C++ library, if you won't want to use Inline::CPP. It is possible instantly with h2xs: h2xs --autogen-xsubs. Install C::Scan from CPAN first.

First, allow me to state that XS a comparatively small group of key phrases which makes wrapping C libraries to be used from perl simpler (see perlxstut and perlxs). To be able to utilize it, however, you'll have to discover the perl API (see perlapi) which takes a shallow understanding of methods the perl compiler works (see perlguts and also the somewhat outdated but nonetheless highly helpful perl guts highlighted). That's a great deal to learn simultaneously. In a nutshell:

  • XS itself => easy
  • perlapi => moderately hard
  • perl inner workings => pretty hard
  • the suggestions above simultaneously => ouch

That being stated, if you wish to wrap a C++ library, take a look in the ExtUtils::XSpp module on CPAN. It arrives with a simple example. The module's not too old but still being enhanced, however it makes wrapping C++ much more convenient.

PS: If you are planning to understand everything at the same time, improve by good examples. Take a look at Dean Roehrich's cook books. Maybe apply certain simple XS modules as models: Parse::ExuberantCTags, Math::FFTW or one of the numerous others on CPAN.