#!/usr/bin/perl use strict; use warnings; my $log=q<10.25.95.100 ab - [05/Aug/2003:12:00:30 -0700] "GET /creative/2|2127274-1>; # note 1 (re above) # print "\$log is $log \n"; # note 2 if ( $log =~ / (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) # capture IP digits \s[a-z]{2,2}\s-\s\[ # match but don't capture space, dash, space (\d+\/[A-Z][a-z]{2,2}\/\d{4,4}) # capture the date : # don't capture the perliminary colon (\d+:\d+:\d+\s-\d{4,4}) # capture time with colons & GMT offset (.*) # dot-slash deprecated, but capture to end /x ) { # extended notation, end condit, print print "\$1=$1, \$2=$2, \$3=$3, \$4 = $4 \n"; # note 3 } else { print "no matches\n"; } # note 4