Since you posted this on the Unix & Linux site, instead of StackOverflow, I'm wondering if something like this isn't what you're looking for:
cat hostlist.txt | xargs resolveip -s
This will only return one IP address though.
Some hostnames will have multiple IP addresses associated with them:
$ host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 74.125.227.18
www.l.google.com has address 74.125.227.17
www.l.google.com has address 74.125.227.16
www.l.google.com has address 74.125.227.20
www.l.google.com has address 74.125.227.19
To get just the list of IPs, one way to do it is:
host <hostname> | grep "has address" | awk '{print $4}'
If you want to stick with Perl, using resolveip:
$ipaddr = qx(resolveip -s $hostname);
Or to get all of the IPs, without executing any shell commands:
use Socket;
@ipaddrs = map { inet_ntoa($_) } (gethostbyname($hostname))[4,];