in reply to gethostbyname("1.1.1") returns 1.1.0.1 ????
Take a look at NetAddr::IP for the validation part. It will even call gethostbyname for you.
Best regards
-lem, but some call me fokat