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?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|