#!/usr/bin/perl -w
use strict;
my ($tmpdate, $tmpip, $tmpreq, $tmpstat);
my (@tmp, @sfall, @sfdate, @sfreq);
my (%recassoc);

my $infile = "access_log-sample.txt";
open (IN, "<$infile") or die "Cannot open $infile: $!";

while (<IN>) {
 chomp;                           # Ditch trailing newline/LF
 @sfreq = split( /\"/ );          # sub-field for request is between "
 @tmp = split ( / /, $sfreq[1]);  # grab the 2nd field [1] & split on spaces
# $tmpreq = $tmp[1];               # the 2nd sub-field is the actual request
# %recassoc{$tmp[1]} = 0;
 $recassoc{$tmp[1]} ++;

 @sfall = split ( / / );          # split the whole request on spaces
 $tmpip = $sfall[0];              # 1st sub-field is the IP address
 # ... 
 # Get the idea?

# print "req=$tmpreq\n";

}

# Output: list of pages with counts:

# Lexical sort by page name:
foreach my $i (sort keys %recassoc) { 

#Not:
#    print "page=\t$i\tcount=%recassoc{$i}\n";
    print "page=\t$i\tcount=" . $recassoc{$i} . "\n";

}
