in reply to Need help with script with a while loop reading file

Move the line
my $res = Net::DNS::Resolver->new( ...
outside the "while (<FILE>)" loop - It does not need to be created for each record.

             "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
        -- Dr. Cox, Scrubs