use Socket; sub IsValidIP { return ($_[0] =~ /^[\d\.]*$/) && inet_aton($_[0]); }