Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing Glob Data as Text

Status
Not open for further replies.

RobertfFC

Programmer
Joined
Nov 27, 2006
Messages
1
Location
CA
I am currently trying to store a Socket as tied data using "IPC::Shareable" for a school project using multithreaded server.

The Shareable module doesn't allow GLOB data to be stored (mind you, it allows virtually every other data type). I remember a few years back using a command to store a socket (or any GLOB data) to and from a string. I used this to save the socket to a file for later use.

I'm having trouble finding this command, or even one similar to it. If you know what this command is, or know another way of storing a glob as text, I'd be very happy!

Thankyou,
Robert Taylor
 
Try Data::Dumper?

Code:
my $data = {
   key => [ "arrayref" ],
   key2 => {
      yet => 'another',
      hash => 'reference',
   },
};

open (SAVE, ">save.txt");
print SAVE Dumper($data);
close (SAVE);

# load the data again
my $new = do "save.txt";

Data::Dumper works with a lot of data types by default. You can specify options (such as $Data::Dumper::Purity) to dump data more efficiently for recalling them later. It may be able to store GLOB data too.

-------------
Kirsle.net | Kirsle's Programs and Projects
 
Kirsle,

I thought about telling him about Data::Dumper as well, but it honestly doesn't sound like that is what he is truly needing. That would enable him share the state of a socket from thread to thread, not the actual socket itself.

I believe there is probably a reason why IPC::Shareable does not allow sharing of GLOB types. Just maybe it's not possible given that framework? Nevertheless, Data::Dumper is always a nice module to know about for any up and coming programmer, so won't hurt for him to try it anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top