Thread Textdatei auslesen und nach bestimmten Filterkrite (7 answers)
Opened by Arasiel at 2004-08-06 11:43

renee
 2004-08-06 11:57
#85467 #85467
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
probier mal (ist ungetestet)
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
my $file = 'path/to/log.dat';
my $out = 'path/to/outfile.txt';

open(READ_LOG,"<$file") or die $!;
my @lines = <READ_LOG>;
close READ_LOG;
chomp(@lines);

my @entries = ();
for(0..$#lines){
 next unless($lines[$_] =~ /\[\d{2}\/\d{2}\/\d{4}/);
 push(@entries,$lines[$_].'; '.$lines[$_+1].'; '.$lines[$_+2]);
}

open(WRITE_OUT,">$out") or die $!;
for(@entries){
 print WRITE_OUT $_,"\n" if(index($_,'is Changed') != -1);
}
close WRITE_OUT;


edit: Fehler verbessert\n\n

<!--EDIT|renee|1091779303-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Textdatei auslesen und nach bestimmten Filterkrite