use strict; use warnings; use Getopt::Long; # the cmd-line-arg --output my $output = 0; GetOptions(  'output=s' => \$output, ); #my $write_file = "/iwmnt/default/main/test-dekabank-01/WORKAREA/dev-deka/trxlogfile.txt"; my $write_file = "c:/trxlogfile.txt"; # print usage, if no logFile is # given as cmd-line-arg die "usage: TrxLogParser.pl [--output FILE] logFile\n"    unless $ARGV[0]; open (lesen1, "<$ARGV[0]")  || die "Kann datei1 Nicht lesen: $!"; open (lesen2, "<$ARGV[1]")  || die "Kann datei2 Nicht lesen: $!"; open( OUT, ">>$write_file" ) || die "Kann die Datei nicht erzeugen: $!"; # the lines and the errorFound-flag my @lines; my %hashref; my $errorFound = 0; my $FrontEndException = 0; my $SocketException = 0; my $ArrayIndexOutOfBoundsException = 0; my $NullPointerException = 0; my $LockedPinException = 0; my $AuthenticationException = 0; my $BusinessServiceException = 0; my $IllegalStateException = 0; my $NumberFormatException = 0; my $Exception = 0; my $NoSuchElementException = 0; my $RemoteException = 0; my $SQLException = 0; my $IOException = 0; my $FileNotFoundException = 0; while ( ) { push @lines, $_; my $Datum = $_ if m/Date: /; my $Zeit = $_ if m/Zeit: /; push @lines, $_; $Zeit =~ s/\D//g; my $dt = "kemuer1".substr($Datum, 12, 4).substr($Datum, 9, 2).substr($Datum, 6, 2).$Zeit; #hier erfolgt das zusammensetzten der string im richtig schlssel string    if ( /^\s*$/ ) {         if ($errorFound eq 1) {         %hashref = ($dt => @lines);         @lines = '';     $errorFound = 0;     }    }    $errorFound = 1 if /Severity: Error/;   $FrontEndException++ if m/FrontEndException/;    $SocketException++ if m/socketException/;    $ArrayIndexOutOfBoundsException++ if m/ArrayIndexOutOfBoundsException/;    $NullPointerException++ if m/NullPointerException/;    $LockedPinException++ if m/LockedPinException/;    $AuthenticationException++ if m/AuthenticationException/;    $BusinessServiceException++ if m/\.BusinessServiceException/;    $IllegalStateException++ if m/IllegalStateException/;    $NumberFormatException++ if m/NumberFormatException/;    $Exception++ if m/\.Exception/;    $NoSuchElementException++ if m/NoSuchElementException/; $RemoteException++ if m/RemoteException/; $SQLException++ if m/SQLException/; $IOException++ if m/IOException/; $FileNotFoundException++ if m/FileNotFoundException/; foreach $dt (keys  %hashref) { print OUT "$dt => @lines\n"; } while ( ) { push @lines, $_; my $Datum = $_ if m/Date: /; my $Zeit = $_ if m/Zeit: /; push @lines, $_; $Zeit =~ s/\D//g; #generierung von einem key my $dt = "serapis1".substr($Datum, 12, 4).substr($Datum, 9, 2).substr($Datum, 6, 2).$Zeit;    if ( /^\s*$/ ) {         if ($errorFound eq 1) {         my %hashref = ($dt => @lines);         @lines = '';     $errorFound = 0;     }    }    $errorFound = 1 if /Severity: Error/;   $FrontEndException++ if m/FrontEndException/;    $SocketException++ if m/socketException/;    $ArrayIndexOutOfBoundsException++ if m/ArrayIndexOutOfBoundsException/;    $NullPointerException++ if m/NullPointerException/;    $LockedPinException++ if m/LockedPinException/;    $AuthenticationException++ if m/AuthenticationException/;    $BusinessServiceException++ if m/\.BusinessServiceException/;    $IllegalStateException++ if m/IllegalStateException/;    $NumberFormatException++ if m/NumberFormatException/;    $Exception++ if m/\.Exception/;    $NoSuchElementException++ if m/NoSuchElementException/; $RemoteException++ if m/RemoteException/; $SQLException++ if m/SQLException/; $IOException++ if m/IOException/; $FileNotFoundException++ if m/FileNotFoundException/; foreach $dt (keys  %hashref) { print OUT "$dt => @lines\n"; } #end for schleife #} } print OUT "FrontEndException:  $FrontEndException\n SocketException: $SocketException\n ArrayIndexOutOfBoundsException: $ArrayIndexOutOfBoundsException\n NullPointerException: $NullPointerException\n LockedPinException: $LockedPinException\n AuthenticationException: $AuthenticationException\n BusinessServiceException: $BusinessServiceException\n IllegalStateException: $IllegalStateException\n NumberFormatException: $NumberFormatException\n Exception: $Exception\n NoSuchElementException: $NoSuchElementException\n RemoteException: $RemoteException\n SQLException: $SQLException\n IOException: $IOException\n FileNotFoundException: $FileNotFoundException\n"; # close the handle close OUT;