I'm an idiot.

Although I am writing for example 
10
1 1 3 3 277
1 1 3 3 277
1 1 3 3 277
...
etc into the memory segment as ints from my C-prog I was expecting perl's
shmread to automagically convert this int data into a string.

The answer is to use 'unpack'

For instance :
$num_recs = unpack "i", $data_str;
gets me the number of records into $num_recs.


-----Original Message-----
From: Rolf Banting [mailto:[EMAIL PROTECTED]]
Sent: 10 July 2001 16:22
To: '[EMAIL PROTECTED]'
Subject: Shared memory


A question on shared memory on Solaris 2.6. 

The scenario is that I want to share data between a C-prog and a perl prog.
I can create a segment fine from perl using either the shmget or
IPC::ShareLite methods and a test C-prog is happily writing data to the
segment. Likewise I can get another C-prog to read the data written by the
test prog. What I can't seem to do is read the data from perl using either
shmread or IPC::ShareLite fetch().

The data being written to the shared seg is very simple:
An int (4 byte) header giving the number of records in the segment.
Each following record consists of 5 int fields.

I get an empty data string whichever method I use to read the data into
perl-world.

Any ideas gratefully received.

Rolf.

Reply via email to