K, I tried this and it didn't work as expected: $code =~ / HTTP\/\d\.\d\" (\d+)/; if (!$code) { print "NEXT\n"; next; } print "$code\n";
The loop just printed NEXT 300 or so times. I was thinking that $code would equal whatever was in the parentheses. Am I still not getting this? -----Original Message----- From: George P. [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 9:48 AM To: Romeyn, Derek Cc: '[EMAIL PROTECTED]' Subject: Re: Regular Expressions http error code On Wed, 12 Mar 2003, Romeyn, Derek wrote: > I have a DB that records HTTP log data like this. I'm horrible at regular > expressions and could use some real help in pulling out the HTTP error code > from lines that look like this. > > 65.248.129.126 - xm1721 [11/Mar/2003:05:41:35 -0800] "POST > /applogic/brpulseappletinfonew HTTP/1.1" 500 16 7 "-" " > 12.235.196.99 - - [11/Mar/2003:05:55:35 -0800] "GET /.com HTTP/1.1" 500 184 > "-" "Mozilla/4.0 (compatible; MSIE 6.0; Win > 12.229.35.165 - - [12/Mar/2003:04:34:11 -0800] "GET /e/t/applogic/spacer.gif > HTTP/1.1" 404 0 "https://www.here.com/t > 24.98.188.254 - - [12/Mar/2003:04:43:19 -0800] "GET > /e/t/kc/images/liquidation_rights.gif HTTP/1.1" 404 0 "https://www.h > 207.5.195.98 - - [12/Mar/2003:04:56:32 -0800] "GET > /e/t/invest/img/spacer.gif HTTP/1.1" 404 0 "https://www.here.com/t > > I'm guessing I need the three digits that are located on each line between > 'HTTP/\d.\d" ' and another ' ' but not sure how to do that. You've almost done it yourself. I've never really worked with HTTP log data, but from the lines that you've given, I would say: my ($error_code); if ($ln =~ / HTTP\/\d\.\d\" (\d+)/) { ($error_code) = $1; } bye George P. > > Thanks much, > Derek > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]