use strict; use Socket; my $ip; open (NAMES, "; close NAMES; chomp (@hosts); open (IPS, ">someoutputfile.txt") || die "Could not create file: $!"; foreach (@hosts){ $ip = inet_ntoa(scalar(gethostbyname($_))); print IPS "$_\n"; } close IPS;