Deane-
My response is embedded.
-Josh

[EMAIL PROTECTED] wrote on 04/19/2006 12:46:24 
PM:
>    1. URL parsing ([EMAIL PROTECTED])
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 19 Apr 2006 10:04:35 -0500
> From: [EMAIL PROTECTED]
> Subject: URL parsing
> To: [email protected]
> Message-ID:
> 
<[EMAIL PROTECTED]>
> 
> Content-Type: text/plain; charset="us-ascii"
> 
> I'm doing some splitting of URLs, and things are getting more and more 
> complicated, what with suddenly needing to allow two, three, or even 
four 
> character TLDs (.us, .gov, .info). I originally thought I'd only need to 

> pass a few common threes--such as .com. 
> 
> Is there a standard Perl library routine (can't use CPAN) that divides 
up 
> URLs? This seems like a common enough task that this particular wheel 
> might already exist. All I need to do is split something like 
> "foo.bar.com" into "foo" and "bar.com". It's for the second bit, the 
> domain, where this issue is suddenly sprouting horns and a pointy tail. 
> Oh, it also needs to ignore any trailing thingies like 
> "foo.bar.com/ignore/this/". 

Not sure of any package, but I know there is an orielly PHP email 
verification example with everything that was current as of the printing I 
have for their php book in 2004. I also believe ICANN keeps a current list 
of valid ones somewhere upon their site.

> 
> Current code is:
> 
>         if ($in =~  /^[^\.]+?\.(com|gov|net|org)$/) {
>            $domain = $in;
>         } else {
>            $in =~ m{^(.*)\.(.+\.(com|gov|net|org)).*$};
>            $domain = $2;
>            $child = $1;
>         }

As far as I know, aside from the ISO 2-letter country abbreviations, the 
TLDs are: biz, com, gov, info, net, museum, org
Though i'm not positive about museum.

> 
> where $in is the URL, less any prefix. The prefixes, "http://"; or 
> "https://";, are already handled by preceding lines, as are any "trailing 

> thingies."
> 
> I've thought of using [a-z]{2,4} to replace the list in the regexps, but 

> that places a big ol' "CAVEAT EMPTOR" in front of the users--one I hope 
> might be avoidable. Plus, I'm afraid of other things popping up, like, 
oh, 
> "dnr.state.wi.us", which is a real URL for Wisconsin DNR, or something 
> like "foo.us.gov".  Both of which would FAIL the current code, as well 
as 
> the [a-z]{2,4} kludge.
> 
> HELP!
> 
> TIA,
> 
> Deane


-----------------------------------------
PLEASE NOTE: 
SeaChange International headquarters in Maynard, MA is moving!
Effective March 1, 2006, our new headquarters address will be:

SeaChange International 
50 Nagog Park 
Acton, MA 01720 USA 

All telephone numbers remain the same: 
Main Corporate Telephone: 978-897-0100 
Customer Service Telephone: 978-897-7300

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to