The subroutines that I am trying to call from one process to the other do indeed pass a bunch of data, some of which is by reference. I understand that this can't be done due to the memory space separation of the two processes. I also understand that I would need to
- serialize the parameters on the caller side, flattening out any references
- deserialize the parameters on the receiving side into the same prototype
- actual function executes with the deserialized parameters, potentially modifying the by reference parameters
- then serialize the modified parameters again to capture the modified values
- deserialize the parameters on the original caller side to update the parameter values
I've put together a very simple example of the first 3 steps where I use Data::Dump for my (de)serialization. However, I am running into an issue.
use warnings;
use strict;
use Data::Dump qw(dump);
my $a = "one";
my $b = "two";
my $c = \$b;
my @d = ($a, $b, $c);
my $str = dump(@d); # ("one", "two", \"two")
my @newD = eval $str;
$newD[0] = "A";
$newD[1] = "B";
${$newD[2]} = "C";
The problem happens on the last line which errors out with
Modification of a read-only value. Why is this the case?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.