SWIG generates perl, python, ruby, ocaml, java, etc. modules from your C(++) code. If you have something that would be much faster in C(++) and it's currently bogging your perl down, take a look at SWIG.

SWIG is mind-numbingly easy to use:

  1. e-slow.pl using straight perl to expand e to 2000 digits (~13.22s to run)
  2. e.c char *e(int k) - same algorithm, but in c
  3. e.i the swig definition file to create the perl module (yes, that's it!)
  4. Makefile commands to make the perl module (change the perl include to fit your box)
  5. e-fast.pl using the new e module (~0.54s to run)