#!/usr/bin/perl -w
use strict;
my ($tmpdate, $tmpip, $tmpreq, $tmpstat);
my (@tmp, @sfall, @sfdate, @sfreq);
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
@sfall = split ( / / ); # split the whole request on spaces
$tmpip = $sfall[0]; # 1st sub-field is the IP address
# ...
# Get the idea?
}
|