The thousand and one reasons to love Perl: [1] Inline::C
Consider this: You have to add support for some electronic payment system to your shopping website. You have to access the payment gateway using a vendor-supplied C library. The documentation suggests you write a CGI script in C, or use the Java Native Interface. Well, Perl to the rescue!
Perl is written in C (Perl6 will be, too). There is an mechanism to create Perl extensions in C, providing access to native libraries. This is frequently used to make Perl interfaces for things like XML parsers, database drivers, OpenSSL, or efficient mathematical algorithms. Using that mechanism is not for the faint of heart however, as it has a steep learning curve. But in Perl, there is always More Than One Way To Do It (tm), and in this case there is Inline::C.
Inline::C is a module that allows you to write Perl subroutines in C. You can just place them in the middle of your Perl files (hence the name, Inline). You can also access external libraries. All of this is surprisingly hassle-free with compilation and linking going on behind the scenes.
use Inline C => Config =>
ENABLE => 'AUTOWRAP',
LIBS =>
'-L/usr/local/edy/lib -L/usr/local/ssl/lib -lssl -lcrypto -ledymallapi',
INC => '-I/usr/local/edy/include';
use Inline C => <<'EDY';
#include<edymallapi.h>
#include<edyerrcode.h>
# just declare the function headers, wrappers around the
# C functions in the edymallapi library will be automagically
# created
int edygeterrorcode();
char *edygeterrormessage( int );
EDY
# and now I can call the C function from Perl
# just like that
print edygeterrormessage( edygeterrorcode());
Have a look at the Inline::C cookbook.



