Thread Nach Muster suchen (11 answers)
Opened by Rambo at 2009-08-18 15:33

Gast TheDude
 2009-08-18 19:21
#124361 #124361
Hatte mal nen aehnliche Situation.. Da hab ich es so geloest..

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use strict;
use warnings;

open (LOG, "log.txt");

my $log;

while (<LOG>) { 
        $log .= $_;
}

my $zeile = 1;

while ($log =~ s/\n/{([$zeile])}/o) {
        ++$zeile;
}

while ($log =~ /S\/R Sending command\{\(\[\d+\]\)\}\-+\{\(\[\d+\]\)\}NRT CC\/(\d+)/g) {
        my $line;
        my $foundstr = $&;
        if ($foundstr =~ /\{\(\[\d+\]\)\}/o) {
                $line = $&;
        }
        if ($line =~ /\d+/) {
                $line = $&;
        }
        $foundstr =~ s/\{\(\[\d+\]\)\}/\n/g;
        print "$foundstr\nAt line: $line\n\n";
}


Bestimmt nicht optimal funktioniert bei mir aber gut.

View full thread Nach Muster suchen