in reply to Parsing to get server info

Use URI.
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
    I tried exactly as you had and got this message:
    Can't locate object method "host" via package "URI::_generic" (perhaps + you forgo t to load "URI::_generic"?) at C:\Perl\bin\url1.pl line 11, <DATA> lin +e 7.
    I do have "URI" module on my Windows NT. Please advise.