Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

shared object

by feelicks (Initiate)
on Dec 22, 2000 at 08:59 UTC ( [id://48009]=perlquestion: print w/replies, xml ) Need Help??

feelicks has asked for the wisdom of the Perl Monks concerning the following question:

perl can do everything - we all know this. but the problem i am having is that i want to know if perl can do a particular something .
perl interacting with C - easy
. embedding perl in C - easy
C interacting with perl - my question

i want to have some C program(s) interact with my perl. i dont want to use anysort of data/procedural exchange (CORBA, etc). i'd basically like to make a shared object in perl. now the only way i can think of doing this is by making a C program that only has embedded perl and the have the other C programs use this C program.
someone on irc told me that this could be done with IPC::Shared but niether perldoc nor cpan knows about IPC::Shared (there is however a IPC::SharedLite but either i dont know what i want or this isn't it)
so does anyone have pointers for me?

note - i speak in general terms but *specifically* i am trying to make a plugin in perl for a program that only supports shared object plugins (presumably C)

Replies are listed 'Best First'.
Re: shared object
by Fastolfe (Vicar) on Dec 22, 2000 at 09:13 UTC
    The best you can do to get this kind of interaction (at least continuing to pursue this avenue) is via shared memory. IPC::Shareable will permit you to share native Perl variables (basically a shared chunk of memory, using Storable). I believe something like IPC::ShareLite will do precisely what you need, as this is (I believe) a simple interface to the raw memory, so it might be easier to use a binary data structure here so that you can easily pull what you need and use it either in C or Perl.
Re: shared object
by PotPieMan (Hermit) on Dec 23, 2000 at 09:33 UTC
    I'm not entirely certain of the situation, but I'll suggest Inline anyway. With Inline, you can write subroutines in other languages (C, C++, Fortran, Pascal, and Python currently) and use them as normal Perl subroutines.

    In this case, though, it sounds like you have a bit of compiled C that you wish to access through Perl. You might be able to write some kind of wrapper (possibly using Inline C), but I think that would be too much work. As such, Fastolfe's advice is probably more pertinent.

    PotPieMan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://48009]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found