Solved

Direct memory manipulation from perl

Posted on 2004-04-12
4
253 Views
Last Modified: 2010-05-18
We have a runtime databank of addresses that are currently accessed with c-programs.  I am hoping to gain the functionality of PERL in several portions of the project that are not time-critical.   Is it possible to have perl directly read and edit this memory bank similarly to what c does?  

For example, I would need to be able to pass a perl script a list of addresses, and then have the script read the existing data from the RAM.  Also, if new variables were created, they would have to be then placed in specific/ newly dedicated locations.  (There is aof course a memeory tracking scheme already in place...)

One might suggest "simply" embedding perl into C, and have C handle the addressing, but I was hoping for a more direct route.  For some reason I can successfullly embed perl in Windows and in several Unix system (inc. Linux), but have been unsuccessful on Onyx (SGI) and Cygwin - the examples in perlembed are unresponsive.
0
Comment
Question by:str8dn
  • 3
4 Comments
 
LVL 1

Author Comment

by:str8dn
ID: 10810559
A further example will probably help...

Say I use C code to create a variable called var1:

double *var1
var1 = (double) malloc (2000);

If I know the address in RAM where the 2000 bit value for val1 is stored, is there a way to acces the data via a PERL script?
Reading var1 with a c-program, and then passing the values is an option, but I was hoping to find a more elegant solution...

Thanks,

str8dn
0
 
LVL 20

Accepted Solution

by:
jmcg earned 500 total points
ID: 10810696
You might consider whether the capabilities of the Sys::Mmap module will do what you need. In particular, see the 'hardwire' method. Even if the module cannot be used as-is, you could mine it for applicable ideas.

http://search.cpan.org/~swalters/Sys-Mmap-0.13/

Also, for some more ideas, see

http://search.cpan.org/~robm/Cache-FastMmap-1.05/

There are a lot of cautions and caveats that apply to using these methods, since Perl usually has a much more "managed" access to data than traditional C.
0
 
LVL 1

Author Comment

by:str8dn
ID: 10819752
I will take a look, thanks.

str8dn
0
 
LVL 1

Author Comment

by:str8dn
ID: 10920640
Thanks for the info.  After looking over it I have decided another, less intensive route, will give me closer to what I really want, with protability to boot.

Thanks again,

str8dn
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading fields from the text file. 4 92
Expect & sshpass package for Solaris 10 x86 15 896
instmodsh - listing perl modules 2 74
Migrate OTRS to newest version. 1 312
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now