Uri Guttman wrote:
>>>>>> "CO" == Chas Owens <chas.ow...@gmail.com> writes:
> 
>   CO> On Fri, Aug 28, 2009 at 16:32, Uri Guttman<u...@stemsystems.com> wrote:
>   CO> snip
>   >> now, as randal also asked, why do you want this? you are just learning
>   >> perl and i am sure this is way above your head in many dimensions. and i
>   >> am positive this is an XY problem where you want X and think Y is the
>   >> solution when there is usually a much better way to do X. what is your
>   >> real GOAL here and i don't mean any technical stuff. why do you want
>   >> this crazy thing?
>   CO> snip
> 
>   CO> I believe, based on reading other emails, that he thought that cyclic
>   CO> data structures were leaked by the Perl program and continued to take
>   CO> up memory, which would mean if you could get the address of the memory
>   CO> you could create a set of Perl objects that would survive the ending
>   CO> of a Perl program and the starting of a new one.  Of course, this is
>   CO> just a misguided attempt to recreate shared memory via a bug that
>   CO> doesn't actually exist (Perl cleans up cyclic dependencies at program
>   CO> end, you only ever "leak" memory while you are running).
> 
> there is a deeper misunderstanding which i mentioned before. you can't
> save memory addresses to disk as you can't make that data reload to the
> same memory location later. PL/I had a solution for this by allowing
> you to create a chunk of ram for allocation and all addresses inside it
> were actually offsets from the beginning of that chunk. this allowed
> that whole chunk and its complex data tree (including cycles) to be
> stored to disk and later reloaded in to ram and usable. but i have never
> heard of any lang doing that in years. it is easier to dump stuff in a
> ram neutral format with storable, dumper, yaml, etc.

Guys,

The idea started off as a way to store data in memory for a very short
period of time between invocations of a CGI application. I then got
thinking about how to do the same thing, without CGI.

For instance, I have a Perl program that generates a hash of numbers.
This program needs to exit completely before another program loads about
a second later, and retrieves the data. In this case, the first program
has no way of passing the hash to the second as a parameter.

I was naive enough to think perhaps I could do something like this:

my %hash = ( this => 'that', these => 'those' );
my $hash_ref = \%hash;

# put the ref's string data in another scalar
my $manual_ref = "HASH(0x8100af0)";

I knew that there were ways to temporarily store the data to disk and
then re-fetch it, but not that the data could avoid the disk while still
being persistent. Thanks to those for the suggestions.

All in all, when I get an idea, I generally like to take the path of
resistance, so I can learn for myself why something does/doesn't work.
For the most part, I don't like to re-invent the wheel, unless
re-inventing the wheel will teach me something important (such as being
told not to do it :) or give me better understanding as to why not to do
it, instead of just being told not to.

It's kind of like the time I was a kid, and I was told not to touch the
cow fence. By touching it, I quickly learnt by my own experience that if
I take a leak at the side of a road, ensure there isn't a steel fence
nearby...

Steve

ps. Thanks for all of the feedback. It's really help me to understand
why not to do it, why it doesn't work, and alternatives to what I wanted
to do. Cheers!

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to