Bill Harpley wrote:
Hi Gunnar,

I tried your suggestions but had no luck :-(

(1)  I tried your idea of using a paragraph separator


     local $/ = '';                      # paragraph mode
     while ( my $entry = <DATA> ) {
         if ( $entry =~ /\[([a-z0-9]{5})]/ ) {
             print "$1\n";
         }
     }

     But the only output which got was :
# script.pl 8252c

        So it found the first line and then quit. So the separator is
obviously the usual "\n";

So it seems.

        At some point, I was planning to convert the long "wrapped"
lines into a single long line, to make the later timestamp analysis
easier.
        This is how the event records appear in the log:

        [2009-01-25 02:21:13,760]TRACE [server-1] [http-80-12]
u...@mydomain.net:090125-022113763:4c213
(LimitVoIPLineImpl.java:call:54)
;- RequestId [8252c] LimitVoIPLine.REQ { accountNumber:=W1931627,
phoneNumber:=1234512345 }
;[2009-01-25 02:21:22,104]TRACE [server-1] [http-80-12]
u...@mydomain.net:090125-022113763:4c213
(LimitVoIPLineImpl.java:call:57)
;- RequestId [8252c] LimitVoIPLine.RES { LimitVoIPLine Result {
Result:=Success } }
;[2009-01-25 02:21:34,675]TRACE [server-1] [http-80-20]
u...@mydomain.net:090125-022134678:467d0
(LimitVoIPLineImpl.java:call:54)
;- RequestId [8252d] LimitVoIPLine.REQ { accountNumber:=W1931627,
phoneNumber:=31455491773 }
;[2009-01-25 02:21:41,354]TRACE [server-1] [http-80-20]
u...@mydomain.net:090125-022134678:467d0
(LimitVoIPLineImpl.java:call:57)
;- RequestId [8252d] LimitVoIPLine.RES { LimitVoIPLine Result {
Result:=Success } }
;[2009-01-25 09:26:27,148]TRACE [server-1] [http-80-8]
u...@mydomain.net:090125-092627068:48de4
;(GetCallForwardStatusImpl.java:call:52) - RequestId [82534]
GetCallForwardStatus.REQ { accountNumber:=W1576824,
phoneNumber:=1234512345
;}
;[2009-01-25 09:26:27,153]TRACE [server-1] [http-80-12]
u...@mydomain.net:090125-092627077:5d89f
;(GetRestrictionListImpl.java:call:53) - RequestId [82535]
GetRestrictionList.REQ { accountNumber:=W1576824,
phoneNumber:=1234512345 }

             So a single event record can be split across several lines
( I assume this is not just a "terminal wrap" problem).
        Is this what you mean when you said that "Probably because your
code splits each entry into multiple @list elements."

Yes.

            Would it be better to convert each record into a single long
line before trying to perform regex match?

Well, it might make the next steps easier, but at first hand we ought to let Perl do the job, right?

Even if "paragraph mode" is not applicable, since you are going to analyze the log file, somehow it makes sense to separate the log entries from each other. Now when I know a little more about the structure of the log, this is what I would try next:

    local $/ = "}\n;";
    while ( my $entry = <DATA> ) {
        if ( $entry =~ /\[([a-z0-9]{5})]/ ) {
            print "$1\n";
        }
    }

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
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