use strict; use warnings; package Server; use IO::Socket::SSL; use Linux::Statistics; use Storable qw(nfreeze); unless (-d "certs") {    if (-d "../certs") {        chdir "..";    } else {        die "Please run this example from the IO::Socket::SSL distribution directory!\n";    } } sub run {   my $socket = IO::Socket::SSL->new(      Listen => 5,      LocalAddr => 'localhost',      LocalPort => 9000,      Proto     => 'tcp',      Reuse     => 1,      SSL_verify_mode => 0x01,      SSL_passwd_cb => sub {return "bluebell"},   ) or die "server: can't open socket over port 9000";   warn "server initialized\n";   while (my $client = $socket->accept()) {      chomp (my $request = <$client>);      next unless $request;      warn "client request: $request\n";      my %hash1 = ( a => 1 );      my %hash2 = ( 1, 2, 3, 4 );      my %hash3 = ( a => '1' );      my $dump1 = nfreeze \%hash1;      my $dump2 = nfreeze \%hash2;      my $dump3 = nfreeze \%hash3;      print $client $dump1;      print $client "\n";      print $client $dump2;      print $client "\n";      print $client $dump3;      close($client);      close($socket);   } } package Client; use IO::Socket::SSL; use Storable qw(thaw); use Data::Dumper; use Safe; sub run {   my $socket = IO::Socket::SSL->new(      PeerAddr => 'localhost',      PeerPort => '9000',      Proto    => 'tcp',      SSL_use_cert => 1,      SSL_verify_mode => 0x01,      SSL_passwd_cb => sub { return "opossum" }   ) or die "client: can't connect to 127.0.0.1:9000";   my $safe = new Safe;   $safe->permit(qw(:default require));   {      no warnings 'once';      $Storable::Deparse = 1;      $Storable::Eval = sub { $safe->reval($_[0]) };   }   warn "client connected to server\n";   print $socket "hash\n";   my $dump1 = <$socket>;   my $dump2 = <$socket>;   my $dump3 = <$socket>;   my $data1 = thaw($dump1);   my $data2 = thaw($dump2);   my $data3 = thaw($dump3);   close($socket);   warn Dumper($data1);   warn Dumper($data2);   warn Dumper($data3); } 1; if (my $pid = fork) {   run Server;   waitpid($pid,0); } else {   sleep 1;   run Client; }