Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: reading C data structure

by asura (Initiate)
on Sep 18, 2012 at 02:11 UTC ( #994168=note: print w/ replies, xml ) Need Help??


in reply to Re: reading C data structure
in thread reading C data structure

My apologies for the ambiguity. I have a variable in a C function (it is a uuid). A perl script needs to use this variable for some operation. Is there a way for me to read this variable from the perl script. I am trying to avoid writing it to a file and reading from it (expensive). Thanks in advance...


Comment on Re^2: reading C data structure
Re^3: reading C data structure
by GrandFather (Cardinal) on Sep 18, 2012 at 02:22 UTC

    That really doesn't get us much further ahead. Do you want write code to call Perl from C (possible), or write code to call C from Perl (also possible), or call an existing C library function from Perl (possible too), or execute an existing Perl script from a C application passing a value through (possible) or execute an existing C application from a Perl script returning a value to the script (also possible), or something else?

    Maybe you should let us in on the secret of what you actually want to do?

    True laziness is hard work

      i am writing a code to call C from Perl. As I said I have one variable in a C code that I want to export. This variable needs to be used by a perl function.

        So in fact it seems you have some C code that you need to access from Perl. The key "word" you need is "XS" and the documentation is in perlxs. You will probably find that documentation heavy going. If you describe what you are doing better you may garner more help. Calling some C code from Perl and returning a result is a very common task.

        True laziness is hard work
Re^3: reading C data structure
by Corion (Pope) on Sep 18, 2012 at 07:08 UTC

    If you want to communicate between two running processes, that will be much harder than just writing/reading the values to a tempfile.

    However, there is Convert::Binary::C, which was made for just that situation, debugging a remote process and dumping C structures from within Perl. Maybe that helps you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2014-09-18 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (109 votes), past polls