Apache log file formats (there are several) consist of space delimited variable width fields:
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTT +P/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en +] (Win98; I ;Nav)"
(The last two quote strings may not be present.)
Every one of those fields except possibly the date and status code can vary in length; so pack and unpack which are primarily designed for fixed length fields and binary work, are the wrong tools for the job.
split is the more applicable tool for your task:
my @bits = split ' ', $line;
|
|---|