sub host_to_user { my $nread ; my $inp ; $/ = CRLF ; while (<$socket>) { chomp; my @data = split/-/, $_ ; print $_ , "\n"; print "The first value is $data[1]\n"; if ($data[1] eq 'THISISTHEEND') { $socket->close ; print " I have executed the close\n"; return 0 ; } } # $socket->close ; #<- position 2 ###print " I have executed the close\n"; # return ; }