Why not use URI? It will tell you what you need to know:
my ($uri) = new URI("http://www.mydomain.com.au/test.html");
print $uri->host,"\n";
It's probably far better to use that than a regexp, though,
of course, you would not be able to validate the validity
of any given Top Level Domain (TLD).
It used to be that top level domains (TLDs) were for countries
(i.e. ".ca", ".au", ".uk") or types of companies (".com",
".net", ".org", or even ".mil") and were fairly predictable.
These days, with countries being invaded and assimilated,
or spliting up because of civil war (frighteningly
frequent in Eastern Europe), the TLDs are always changing.
The
ISO-3166
specifies the country codes for various national entities.
Added to this is the likes of Esther Dyson, chairperson of
ICANN, which is proposing
to add things like ".museum" to the TLD namespace.
Don't forget the
UTF-5 encoded "iTLDs" which are being
issued by
VeriSign
and others. These look really wacky unless your browser
supports them, but they mean things like ".com" in Japanese,
Chinese, Korean, and other languages that aren't based on
the Latin character set.
The only way to know for sure, if only for a short period of
time (i.e. a month or so) before requiring an update, is to
process the root zone file which lists all the servers
for all the active domains.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.