in reply to Can I pass a reference between two scripts?

My brother tells me that even in C (which has pointer arithmetic) the value of a pointer in one process is meaningless to any other process. In other words, consider a C pointer that at a particular moment has a value of 0x12A99B and which points to a char having the value 'Y'.

At that exact moment, setting some other C pointer in some other process to that exact value of 0x12A99B will not result in a value which when dereferenced is 'Y'.

Perl is written in C and in this case would share C's limitations. The addresses in memory are not meaningful when sent from one process to another concurrent one. So the short answer is no, you cannot.

Sure, serializing your array is the right answer for how to do it, but if you want to be off-the-wall then convert your array to XML, write it to a file and then read it into your other process.

Who needs serialized arrays anyway? All data should always be transferred as XML. That way you can practice the skills you will need for SOAP, the Dublin Core and other XML implementations.

  • Comment on Re: Can I pass a reference between two scripts?

Replies are listed 'Best First'.
Re: Can I pass a reference between two scripts?
by Abigail (Deacon) on Jun 28, 2001 at 03:39 UTC
    That limitation has nothing to do with C. The limitation has all to do with the process model the operating system uses. Suppose it would be possible to pass a reference (or a pointer) to a child process. There are at least two problems with that:
    • What do you think is going to happen if the parent process dies?
    • Pointers (and hence, references), are nothing more than integers - virtual addresses to some place in memory. If one could pass a pointer or a reference, it would mean one process can muck around in the data space of another process. Regardless of whether that pointer was passed. Just think of those implications. No security! Script kiddie heaven.

    -- Abigail

      My point was that even C cannot make a pointer whose value is set in one process meaningful in another. If C cannot do it then a higher level language like Perl, which doesn't even allow pointer arithmetic, couldn't either.

      Aren't you the Abigail who got a nice thank you in one of the Perl releases? Although we have many knowledgeable people here it is nice to see a distaff one.

        I don't think I, or any other Abigail, got a special thank you in any of the Perl releases. Come to think of it, I don't think Perl releases come with thank yous. The list would be too long anyway. ;-).

        I am in the acknowledgement sections of a few Perl books though, if that is what you mean.

        -- Abigail