spyder@local:~> perl tt.pl
0 [error]
1 [error]
Thread 1 terminated abnormally: Bad arg length for Socket:

ack_sockaddr_in, length is 0, should be 4 at /usr/lib/perl5/5.10.0/i586-linux-thread-multi/Socket.pm line 386.
Thread 2 terminated abnormally: Bad arg length for Socket:

ack_sockaddr_in, length is 0, should be 4 at /usr/lib/perl5/5.10.0/i586-linux-thread-multi/Socket.pm line 386.
2 [error]
Thread 3 terminated abnormally: Bad arg length for Socket:

ack_sockaddr_in, length is 0, should be 4 at /usr/lib/perl5/5.10.0/i586-linux-thread-multi/Socket.pm line 386.
ошибки вываливаются, я думаю надо поставить проверку на не пустое значение $ip что бы их небыло