in reply to Re: prob in unfolding Dumper Data at the Server Side Socket prog
in thread prob in unfolding Dumper Data at the Server Side Socket prog

Thanks for the pointing out the $d->Dump to be send with the syswrite. Now I am getting the value in Server Side. But eval is not giving the data back. The output is coming as follows::> Dumping the buffer $VAR1 = undef;
Though While I am again using
$socket->recv($buffer , BUFF_LEN); my $a = [ $buffer ]; my $d = Data::Dumper->new([ $buffer , $a ]); my $c = $d->Dump; print Dumper($c);
The above code is unfolding the details. can you pls comment on this.
Re,
SR
  • Comment on Re^2: prob in unfolding Dumper Data at the Server Side Socket prog
  • Download Code

Replies are listed 'Best First'.
Re^3: prob in unfolding Dumper Data at the Server Side Socket prog
by Joost (Canon) on May 19, 2007 at 17:08 UTC
    Ok, well a few comments:

    • The output is coming as follows::> Dumping the buffer $VAR1 = undef;
      That's certainly not the output of the code you just posted.

    • $socket->recv($buffer , BUFF_LEN); will break the message if BUFF_LEN is smaller than the actual size of the message sent.

    • my $a = [ $buffer ]; my $d = Data::Dumper->new([ $buffer , $a ]); my $c = $d->Dump;
      What's that all about? You are receiving a serialized structure in $buffer you should not-store that string in a new structure and serialize it again, you should eval() the $buffer. As already stated by me and others in this thread.

    • You appear to be confused about the use of Data::Dumper. Let me just note that it's easy to test the dump/restore stage without sending anything across a pipe/stream/socket:
      #!/usr/bin/perl -w use strict; use Data::Dumper; my $fancy_struct = { a => "aaah", b => "beeh", }; my $dumper = Data::Dumper->new([$fancy_struct]); $dumper->Purity(1); my $serialized = $dumper->Dump; print "Serialized form: $serialized"; my $VAR1; eval $serialized || die; my $new_fancy_object_clone = $VAR1; print "a = $new_fancy_object_clone->{a}\n";