Where exactly is that message coming from? If from whoisip_query then you have a bug to report to the author of Net::Whois::IP. The bug would be that the module does not cope correctly with the bad data you are supplying - www.yahoo.com is not an IP address.
As for solving your problem ...
for i in `cat list-of-domains`; do host -t NS $i; done