in reply to Parsing to get server info
use URI; my %hostcount; while (<DATA>) { my $u = URI->new($_); $hostcount{$u->host}++; } foreach my $host (keys %hostcount) { print "$host = $hostcount{$host}\n"; } __DATA__ http://riverserver/dir1/dir2/index.html http://riverserver/dir1/dir2/index.html http://perlmonks.org/index.pl http://webserver.company.serv/Adir/Bdir/thePage.cfm http://riverserver/dir1/dir2/index.html http://webserver.company.serv/Adir/Bdir/thePage.cfm
Output:
webserver.company.serv = 2 riverserver = 3 perlmonks.org = 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Parsing to get server info
by Anonymous Monk on Jul 15, 2003 at 16:02 UTC |