in reply to Parsing to get server info

If you're sure that the data you process contains only valid URLs, you can do it a bit more conveniently with:

$link =~ m{http://([^/]+)}; $server = $1;
Hope this helps, -gjb-

Replies are listed 'Best First'.
Re: Re: Parsing to get server info
by l2kashe (Deacon) on Jul 15, 2003 at 14:29 UTC
    As an add on here. maybe
    $line =~ m{^https?://([^/]+)}; $server{$1}++; for ( keys %server ) { print "$_ : $server{$_}\n"; }
    This way it will also catch https URLs. Though using a module as recommended below is probably the best way.


    MMMMM... Chocolaty Perl Goodness.....