Ok, this one is a long shot, but i figure if anyone would know or have some sly tricks up their sleeves, it would be the monks....

Short version:
Is there a way to dynamically include perl code into a C program at runtime?

Long version:
i'm creating a daemon and originally planned to use shared libraries for dynamic functionality (depending on a config file, it would either load library A to interface with the mysql database, or library B to interface with a special format of text file, etc). This daemon would have some special characteristics that only a persistant daemon would run. I was hoping to be able to use pre-existing code to base the dynamic libs on...

Problem is, when i first wrote these programs, i wrote one (the file parser) in C and another (the mysql interface) in perl (using DBI). Rather than rewrite the perl code in C, i decided to experiment - i tried perlcc, with no avail (creating shared libraries is aparently disabled) I read up on Calling Perl from C Programs as well, but that appeared to only be able to compile in perl statically to the executable. So my question is this: is there a way of creating an equivilant system to loading a .so into a C program, instead using perl? Or am i stuck having to either rewrite it in C or exec the perl program as a seperate executable (not desirable)?

In reply to including perl dynamically into C by cyberconte

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.