SPUG: domain from URL (was: better way?)
Scott Blachowicz
Scott.Blachowicz at seaslug.org
Tue Aug 10 18:18:56 CDT 1999
> > my ($dom) = (referer() =~ m{//([^/]+)/};
>
> Typo: Forgot your trailing parenthesis (just before the semicolon).
Oops.
> Also, a clarification on th original question:
> Do you want the fully qualified hostname (host + domain),
> or just the _domain_? Everyone so far has done just the former.
OK...minor adjustment...how about something like this:
my ($hostname, $domain) = (referer() =~ m{
// # Starting double-slash
([^\./]+) # a string of non-dot, non-slash chars
(\.[^/]+) # a dot followed by one or more non-slashes
? # zero or one of the above
/ # Ending slash
});
$domain = getdomainname() if ! $domain;
my $FQDN = "$hostname$domain";
where the 'getdomainname' function is left as an exercise for the reader :-)).
Scott.Blachowicz at seaslug.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list