Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Direct memory manipulation from perl

Posted on 2004-04-12
4
255 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTP Error 502.2 - Bad Gateway 3 222
Union rows in array that have common elements (Part 2) 4 78
File Find regex problem 4 64
read an xml file in perl 2 49
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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

840 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