- Using named captures:
while(<>) { m{ ^\S+ # Client host/IP \s\S+ # Identd user \s\S+ # HTTP auth user \s\[.*?\] # Date/timestamp \s"GET\s(?<REQ_URL>/\S*)\s[^"]*" # URL path requested \s\d+ # HTTP status code \s\d+ # Bytes sent in body \s"\Q$site_root\E(?<REF_URL>/[^"]*)" # Referring URL path }x or next; $tally{ "$+{REF_URL} => $+{REQ_URL}" }++; }