in reply to learn sth.
You might find it much easier to use the IO::Socket module to do socket programming.
Autark.