You don't. Or, at least, your question is open to so many different interpretations it's not possible to know what you actually want to do.
Things you may want to do are:
- Read binary data from a file written by a C application
- Pass data from XS back to Perl
- Recreate in Perl a data structure serialised by a C application
- Recreate in Perl a C data structure specified in a .h file
- any number of other possible scenarios I haven't thought of
True laziness is hard work
| [reply] [Watch: Dir/Any] |
Here is a small sample from CPAN of some of the ways to interpret your question:
Data::Struct
Simple struct building
Data-Struct-1.701 - 23 Nov 2011 - Johan Vromans
SOOT::Struct
Perl interface to generate new C-level struct types
SOOT-0.17 - 25 Dec 2011 - Steffen Müller
Win32::API::Struct
C struct support package for Win32::API
Win32-API-0.68**** (3 Reviews) - 10 Apr 2012 - Cosimo Streppone
Thrift::Parser::Type::Struct
Struct type
Thrift-Parser-0.03 - 16 Sep 2012 - Eric Waters
Class::Struct::FIELDS
Combine Class::Struct, base and fields
Class-Struct-FIELDS-1.1 - 05 Jul 2001 - B. K. Oxley (binkley)
Class::Struct
declare struct-like datatypes as Perl classes
perl-5.16.1*** (9 Reviews) - 08 Aug 2012 - Ricardo SIGNES
Inline::SLang::Struct
Support for structures
Inline-SLang-1.00 - 04 Jan 2005 - Douglas Burke
Inline::Struct
Manipulate C structures directly from Perl.
Inline-Struct-0.06*** (1 Reviews) - 11 Jun 2001 - Neil Watkiss
I hope life isn't a big joke, because I don't get it.
-SNL
| [reply] [Watch: Dir/Any] |
It's unfortunate: The real question most probably has a good answer. But it's impossible to know what that answer is given the ambiguity and terseness in how you chose to communicate that question to us. I wish we knew what it is that you actually are trying to do.
| [reply] [Watch: Dir/Any] |
| [reply] [Watch: Dir/Any] |
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.
| [reply] [Watch: Dir/Any] |
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
| [reply] [Watch: Dir/Any] |