views:

102

answers:

1

Hello,

Is it possible to re-create the Net::Telnet connection if I have its memory location ?

how can i turn Net::Telnet=GLOB(0x1b50ff0) string to a Net::Telnet object again ?

Thanks.

+1  A: 

UPDATE

You can not re-use your object in 2 separate processes as it seems from your comments you are trying to do - one will NOT see the other's memory/address space. You can only do one of 3 things:

  1. Re-create the object from scratch to be the duplicate of the other object in a different program, but only if the object's class supports serialization/de-serialization (usually done via saving object state using Data::Dumper, Storable or other methods). I don't know if Net::Telnet can be handled that way.

    Just to be clear, your second program will obtain a COPY of the object once deserialized, which has nothing to do with the original object.

  2. Allow the client to talk to the server and send Telnet commands, which the server passes to Net::telnet object and tells the client the result. Basically, the server acting as a telnet proxy for the client. The client should refer to server's Net::Telnet objects via their IDs, as mentioned in the registry explanation in my original answer.

  3. Use shared memory to store Net::Telnet object if the client and server reside on the same physical server.


ORIGINAL ANSWER

You can try looking at Acme::Ref which un-stringifies a reference... I never used it so can't guarantee it works well or works with specifically Net::telnet.

I agree with the comment posted above that if you need to do this, you most likely are not applying a correct solution to your underlying problem - it would help if you provided more details of what you're trying to achieve high-level.

You should almost never have to deal with stringified reference as opposed to an object reference. If you're within the bounds of your own process, then you can pass the object reference around (or make it global if you really must). If you are using some sort of inter-process communication and an external process needs to refer to one of Net::Telnet objects in your program, you need to create a registry of Net::Telnet objects (could be just an array) and reference them by an index in the registry.

DVK
i'm not in the same process, it's a client/server communication ..
Ricky
Then go with the registry (sounds fancy, but basically store a list of all your objects in a hash or an array, and pass a hash key or array index as an ID of the net::telnet object between processes/programs.
DVK
Thanks, it works as simple telnet proxy ...It did the job. thanks :)
Ricky