in reply to Re: resurrecting objects?
in thread resurrecting objects?

I understand and we may implement it as proposed (have never overloaded
in Perl before :-), but what I wanted was to get the reference back from the
string that describes it, I know I may be missing something.
Is it possible to backtrack in this way, or is the conversion conducted
by the interpolation irreversible?

Thanks,
me

---Strange Currencies

Replies are listed 'Best First'.
Re: Re: Re: resurrecting objects?
by davorg (Chancellor) on May 03, 2001 at 15:08 UTC

    OK. I think I understand now. Your problem is that somewhere along the line you have "stringified" your object and turned the reference into a string. There's no way (that I know of) to undo this, so you'll need to find out where the stringification takes place and fix that piece of code. You're looking for somewhere where the reference is quoted unnecessarily.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

      I suspect that you could find the pointer again using unpack with the -P option to follow a pointer back to where the object is (hopefully) still in existence.

      It would take a serious hacker to successfully do this, and only the insane would consider it. I say this with full knowledge that this may motivate you to demonstrate what a wizard you are by going out and doing it. What is worse is that I feel no remorse in saying this, I am confident that you of all people are capable of doing it, and I am sure you would find it fun in a crazy sort of way.

      Aren't I a jerk when I want to be? :-P

        But finding the pointer wouldn't be of much use unless you (brace yourself) create a dummy object and then overwrite its pointer with your newly re-found pointer. When you are done, you overwrite the pointer with the original value again.

        The biggest problem with this is that your new object reference didn't increment the reference count so the object could be destroyed out from under you at any time (if it wasn't already destroyed before you started).

        For some tips on getting started on this, see (tye)Re: Creative use of pack/unpack.

                - tye (but my friends call me "Tye")
Re: Re: Re: resurrecting objects?
by MeowChow (Vicar) on May 04, 2001 at 00:28 UTC
    Would I be correct in guessing that your stringified reference comes out of a hash key? If so, you may want to have a look at Tie::RefHash. Otherwise, just create a hash table mapping pointer strings back to their original objects, as tye suggests.

    If, however, by resurrecting, you mean reclaiming an object that was deleted by garbage collection (ie. refcount went to 0), this would be a very dangerous and unwise thing do, for reasons that are fairly obvious.

       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print