Bill Harpley wrote:

[2009-01-23 09:20:48,719]TRACE [server-1] [http-80-5] a...@mydomain.net
:090123-092048567:f5825 (SetCallForwardStatusImpl.java:call:54) -
RequestId [81e80] SetCallForwardStatus.REQ { accountNumber:=W12345,
phoneNumber:=12121212121, onBusyStatus:=true, busyCurrent:=voicemail,
onNoAnswerStatus:=false, noAnswerCurent:=voicemail,
onUncondStatus:=false, uncondCurrent:=voicemail }

Is an entry divided into multiple lines? If so, and if the entries are separated by one or more empty lines, you probably want to enable paragraph mode.

http://perldoc.perl.org/perlvar.html#$INPUT_RECORD_SEPARATOR

chomp(@list=<DATA>);

It seems to be unnecessary to read the whole log file into an array. chomp()ing seems to be unnecessary, too.

        $entry =~ /\[([a-z0-9]{5})\]/;

You'd better check whether the regex matches.

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

The first thing that puzzles me is that it obviously extracting the
RequestId substring correctly, it seems to complain about the "$1\n"
expression in line 16.
This looks quite OK to me and I am baffled why I am getting this
message.

Probably because your code splits each entry into multiple @list elements.

The other thing that puzzles me is that there can only be a single
REQ/RES pair in the file with a given ID. So the RequestID should not
appear more than twice in the
The output list. Yet there are many instances where the RequestID
appears more than twice.

$1 retains its value from the latest successful match until the next time the regex matches successfully.

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