in reply to Extracting a domain name from a url
From -> http://yahoo.co.uk/notfound.html
extract only -> yahoo.co.uk
rhesa already suggested using a specialized module, which yields a superior solution, which is superior because it uses a a specialized module (and that's generally the case), but this shouldn't be hard to do with a match or split, in which case some familiarity with elementary regexen should help you. In particular the following should be fine for you:
my $url='http://yahoo.co.uk/notfound.html'; my $host=(split m(/+), $url)[1];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Extracting a domain name from a url
by rhesa (Vicar) on Oct 15, 2006 at 18:26 UTC | |
by abachus (Monk) on Oct 15, 2006 at 23:02 UTC | |
by ministry (Scribe) on Oct 16, 2006 at 01:10 UTC | |
by ikegami (Patriarch) on Oct 16, 2006 at 01:49 UTC |