i think i got it working correctly. thanks for your help:

    my ($ip, $ident, $userid, $time, $cgi, $url, $proto, $status,
        $size_tx, $ref, $ua, $size_rx, $re_time) = /^
            ([-0-9\.]+)\                            # ip address
            (\S+)\                                  # identity
            (\S+)\                                  # userid
            \[([^]]+)\]\                            # time
            "([A-Z]*)[\ ]{0,1}                  # cgi
            ([^\ ]*)[\ ]{0,1}                       # url
            ([^"]*)"\                               # proto
            ([-\d]+)\                               # status code
            ([-\d]+)\                               # server doc size
            "([^"]*)"\                              # referring url
            "([^"\\]*(?:\\["\\][^"\\]*)*)"\     # user agent
            ([-\d]+)\                               # request size
            ([-\d]+)                                    # time to
process request
        $/x;


LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O"


On Thu, Nov 22, 2012 at 10:29 AM, Shawn H Corey <shawnhco...@gmail.com> wrote:
> Oops, I found an error my parser. Here's version 1.0.2:
>
> DATA_LOOP:
> while( my $line = <DATA> ){
>   print $line;
>
>   my @captured = ( '' );
>   my $inside = 0;
>
> CAPTURE_LOOP:
>   while( 1 ){
>
>     if( $line =~ m{ \G ( [^"\\]+ | \\ ["\\] ) }gcx ){
>       $captured[-1] .= $1 if $inside;
>     }elsif( $line =~ m{ \G \" }gcx ){
>       $inside ^= 1;
>       push @captured, '' if ! $inside;
>     }else{
>       last CAPTURE_LOOP;
>     }
>
>   }
>
>   if( $inside ){
>     warn "missing closing quotes\n";
>   }else{
>     pop @captured; # last item is a bogus empty string
>   }
>
>   print "\t$_\n" for @captured;
>   print "\n";
> }
>
> __DATA__
> "something" 444
> \"escaped quote\" 321
> "\"esc quote\" other stuff" 567
> "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; . NET
> CLR 1.1.4322; msn OptimizedIE8;ESMX)" 556 "\"Mozilla\"" 555
>
>
>
> --
> Just my 0.00000002 million dollars worth,
>         Shawn
>
> Programming is as much about organization and communication
> as it is about coding.
>
> Why fit in when you can stand out?
>         Dr. Seuss
>
> The only way that problems get solved in real life is with a lot of
> hard work on getting the details right.
>         Linus Torvalds
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to