Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am using gethostbyname() to check if the domain part of an email address has a valid DNS. Why is it that for some addresses like say <foo@bar.com> 'bar.com' has a DNS entry but for other addresses such as <foo@baz.com> 'baz.com' does not have a DNS entry but 'www.baz.com' does. In real life both these email addresses are valid and deliverable, its just that when you check the domain part with gethostbyname() you need to append the 'www.' prefix. I have settled on this:
for (keys %emails) { my ($domain) = $_ =~ m/<[^@]+@([^>]+)>/; my $dns = gethostbyname($domain) || gethostbyname("www.$domain"); $dns = $dns ? "OK DNS" : "No DNS"; print "$dns email: $_ page(s): $emails{$_}\n"; }
Can someone please explain this seemingly random requirement for 'www.' to me?
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: gethostbyname() and www prefix
by pjf (Curate) on Oct 08, 2001 at 03:49 UTC | |
by tachyon (Chancellor) on Oct 08, 2001 at 13:35 UTC | |
|
Re: gethostbyname() and www prefix
by mandog (Curate) on Oct 08, 2001 at 02:54 UTC | |
|
Re: gethostbyname() and www prefix
by jj808 (Hermit) on Oct 08, 2001 at 03:17 UTC | |
|
Re: gethostbyname() and www prefix
by rob_au (Abbot) on Oct 08, 2001 at 09:05 UTC | |
|
Re: gethostbyname() and www prefix
by converter (Priest) on Oct 08, 2001 at 03:01 UTC |