Perl/regex help

Deeko

Lifer
Jun 16, 2000
30,213
12
81
Ok...this is supposed to extract the file from a web log in this format:

213.0.241.9 - - [17/Aug/2003:06:29:36 -0400] "GET /~issac2003/main.html HTTP/1.0" 200 1958 "http://www.google.com/search?q=issac-2003&ie=ISO-8859-1&hl=es&btnG=B%FAsqueda+en+Google&lr=" "Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)"

basically...i'm trying to get what's in the parenthasis, directly following the GET statement.

if($log =~ /.*("GET )(\/.+ )(.*").*/)

if I'm thinking correctly....$2 should be the filename. in the above example, /~issac2003/main.html. However, $2 extracts the entire rest of the line. Strange, since $3 is what I'd expect it to be...any ideas?
 

Deeko

Lifer
Jun 16, 2000
30,213
12
81
actually i figured it out.

if($log =~ /.*"GET (\S+).*/)

works like a charm.