Thread fehler beim ausgeben eines hashes (7 answers)
Opened by mr-sansibar at 2006-05-22 18:17

mr-sansibar
 2006-05-22 20:12
#7739 #7739
User since
2006-04-13
90 Artikel
BenutzerIn
[default_avatar]
vielen dank.
bin noch anfänger.

kannst du mir noch ein tipp geben wie ich ein hash ausgeben kann, am besten ich gebe dir den ganzen code, dass müsste für Dich kein problem sein :blush:
habe zuvor mit c++ prgrammiert und mir fällt es einwenig schwer mit perl. kannst du mir eine IDE empfehlen, wo ich zumindestens debigging machen.

vielen dank !!!

Code: (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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 ( <lesen1> ) {

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 ( <lesen2> ) {

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;

View full thread fehler beim ausgeben eines hashes