in reply to Test the syntactic validity of a domain name
It matches newlines at the end of the domain name :-
\z instead of $ in the regexps would fix it for recent perls as would a judicously placed chomp - but I'm sure you know this already!print could_be_a_host("www.domain.com\n"); # says 1
In Section
Cool Uses for Perl