in reply to MX Record Lookups

The Net::DNS module wraps much of that for you - no need to rewrite all of it. After the Net::DNS docs:

use Net::DNS; my @mx = mx($domain);
, minimally, or
use Net::DNS; my $resolvewr = Net::DNS::Resolver->new(); my @mx = mx $resolver, $domain;
which allows for error handling and other tricks.

After Compline,
Zaxo