Just a suggestion (i'm really not an expert):
IO::Socket is a
IO::Handle and as all handles it autoclose when it goes out of scope and in other circumstances too (filehandle have close on exec: see
perlipc ).
In general sense, Perl does a lot of kind things for you, behind the scenes, garbage collection is one of theese.
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.