It's hard to tell exactly since you didn't show us your code. But I guess that you pass in undefined value or empty value (the second arg for IP) to the Socket::pack_sockaddr_in function. You may need to say,
my $port = 8080;
my $ip = '192.168.1.1';
my $sockaddr = pack_sockaddr_in($port, inet_aton($ip));