use IO::Socket::INET; my $sock = IO::Socket::INET->new( Proto => 'UDP', LocalPort => $port, ) or die("Can't create socket: $!\n");