Solved

Direct memory manipulation from perl

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Perl Script to append xml file 32 184
transpose into pipe delemited 8 65
PERL variable conundrum 9 84
Insert Text into odbc.ini file 15 63
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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

20 Experts available now in Live!

Get 1:1 Help Now