Inline::C is the stuff that dreams are made of. I'm serious.

Here's how you use Inline::C:

  1. Find some C code that you want to use, preferably in ANSI C format, which is pretty standard stuff.
  2. Plonk your C code into Perl using a here document parameter to use Inline::C
  3. Use the functions directly from Perl as if they were there all along.
I know, it sounds too good to be true, but it is. No XS is required, which is good because most of that stuff never made much sense to the average Perl hacker.

If you have just a library file, like a shared library, or a statically linked one, it's not that hard to plow that into Inline::C using the header file. It's just a few more options.

If you're feeling particularly adventurous, you would try and convert any library output from nasty C structures into Perl ones using the low-level conversion routines that are part of XS. For instance, instead of getting back a linked list in C, you could convert to an AV*, or Array Value, so that it is just a regular Perl array, and it just requires making a quick "wrapper" function. Since you're working one-on-one with the Perl interpreter, right inside it, actually, you can make hashes, classes, the works.

As a bonus, when you're merging your C code with Perl, you can choose when Perl is better and when C is. You can work back and forth within the same program as required. So this way you can have the output of the C function go through an intermediate Perl function, sorting or substituting perhaps, and then back into C for some final work before being used in the main Perl program. It's really incredible what you can do.

I know, I'm gushing, but it is really very cool stuff.

In reply to Re: Software simulation using Perl by tadman
in thread Software simulation using Perl by kevin_i_orourke

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.