use strict; use warnings; use Getopt::Long; use IO::File; use File::Glob; use Data::Dumper; use File::Find; use Time::HiRes qw(gettimeofday); # the cmd-line-arg --output my $output = 0; GetOptions( 'output=s' => \$output, ); my $fh1 = new IO::File; my $fh2 = new IO::File; my $fh3 = new IO::File; my $write_context = "context.csv"; my $write_message = "message.csv"; my @logfilelist =glob("*.log"); my @array; my $line; my $counter=0; my $item=0; my $MessageFound=0; my @list; my $t0 = gettimeofday(); foreach my $file(@logfilelist) { my $tmp_file=substr($file,0,-4); $fh1->open("> h:/$tmp_file-$write_context") || die "$write_context kann nicht erzeugt werden"; $fh2->open("> h:/$tmp_file-$write_message")|| die " $write_message kann nicht erzeugt werden"; $fh3->open("<$file") || die "$file konnte nicht zum lesen geƶffnet werden"; while(<$fh3>) { if(/Context:/) { $line = chomp($_); $line= substr($_,10,length($_)); @array = split(/ /, $line); $line=''; #print $fh1 Data::Dumper->Dump([\@array], [' split / /']); #print $fh1 "$counter;",@array,"\n" #print $fh1 @array, "\n"; foreach my $idx (0 .. 5) { $array[$idx].=";" } if($array[2] ne ";") { $counter++; #$MessageFound=0; #print $fh1 Data::Dumper->Dump([\@array], [' split / /']); print $fh1 "$counter;",@array,"\n" } } if(/Message:/ || $MessageFound) { if($array[2] ne ";") { $MessageFound=1; if($_ =~ /^\n/) { chomp($line); $line .= "/ende\n"; print $fh2 "$counter|$line"; $line = ''; $MessageFound=0; } else { chomp($_); $line .= $_ }; } } } } $fh1->close; $fh2->close; my $t1= gettimeofday(); my $elapsed = $t1 - $t0; print "$elapsed Sekunden \n";