Re: How to send struct data over socket?
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 15 Jun 2005 12:53:52 -0700
poohc1234@xxxxxxxxx wrote:
> Hi,
> Thanks for the reply. I have used Data::Dumper to stringify the
> structure into a long string, but the part that still confuses is once
> the long string is transmitted over the socket, how do I refill the
> data fields of the struct?
Did you actually read the documentation that was suggested to you in
the previous replies?
>>From `perldoc Data::Dumper` :
Given a list of scalars or reference variables, writes out
their contents in perl syntax. The references can also be
objects. The contents of each variable is output in a
single Perl statement. Handles self-referential structures
correctly.
The return value can be "eval"ed to get back an identical
copy of the original reference structure.
So, if you have
my $saved = Dumper(\%ReallyBigStruct);
and you've sent $saved through your socket, you can get back to your
data by doing:
my $restored = eval $saved;
my %CopyOfReallyBigStruct = %$restored;
(Or, if you want to skip the temp variable...)
my %CopyOfReallyBigStruct = %{eval $saved};
HTH,
Paul Lalli
.
- Follow-Ups:
- Re: How to send struct data over socket?
- From: poohc1234
- Re: How to send struct data over socket?
- References:
- How to send struct data over socket?
- From: poohc1234
- Re: How to send struct data over socket?
- From: Jim Gibson
- Re: How to send struct data over socket?
- From: poohc1234
- How to send struct data over socket?
- Prev by Date: Re: Selecting a variable - Newbie question
- Next by Date: Re: How to send struct data over socket?
- Previous by thread: Re: How to send struct data over socket?
- Next by thread: Re: How to send struct data over socket?
- Index(es):
Relevant Pages
|
|