7 Einträge, 1 Seite |
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
sub work_with_file {
my ( $filename, $addon ) = @_;
if ( open( FILE, "< $filename" ) ) {
while (<FILE>) {
$Datum = $_ if m/Date: /;
$Zeit = $_ if m/Time: /;
$errorFound = 1 if /Severity: Error/;
$lines .= $_;
#generate a new hash-hey
if ( $Zeit && $Datum && $errorFound ) {
$Zeit =~ s/\D//g;
$Datum =~ m/(\d+)\.(\d+)\.(\d+)/g;
$dt = $3 . $2 . $1 . $Zeit . "_" . $addon;
$Datum = $Zeit = "";
}
#put the error snippel in hash
if ( /^\s*$/ or eof ) {
$hash{$dt} = $lines if $errorFound;
$errorFound = 0;
$lines = '';
}
}
close(FILE);
}
}
work_with_file($file1, ARGV[0]);
work_with_file($file2, ARGV[1]);
1
2
3
4
5
6
7
8
9
10
11
my $array_ref = \@array;
subroutine($array_ref);
# oder
my $array_ref = [1,2,3];
subroutine($array_ref);
# oder
subroutine(\@array);
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
while ( <dat1> ) {
$Datum = $_ if m/Date: /;
$Zeit = $_ if m/Time: /;
$errorFound = 1 if /Severity: Error/;
$lines .= $_;
#generate a new hash-hey
if ($Zeit && $Datum && $errorFound){
$Zeit =~ s/\D//g;
$Datum =~ m/(\d+)\.(\d+)\.(\d+)/g;
$dt = $3.$2.$1.$Zeit."_".$ARGV[0];
$Datum = $Zeit = "";
}
#put the error snippel in hash
if (/^\s*$/ or eof) {
$hash{$dt} = $lines if $errorFound;
$errorFound = 0;
$lines = ''
}
}
close dat1;
while ( <dat2> ) {
$Datum = $_ if m/Date: /;
$Zeit = $_ if m/Time: /;
$errorFound = 1 if /Severity: Error/;
$lines .= $_;
#generate a new hash-hey
if ($Zeit && $Datum && $errorFound){
$Zeit =~ s/\D//g;
$Datum =~ m/(\d+)\.(\d+)\.(\d+)/g;
$dt = $3.$2.$1.$Zeit."_".$ARGV[1];
$Datum = $Zeit = "";
}
#put the error snippel in hash
if (/^\s*$/ or eof) {
$hash{$dt} = $lines if $errorFound;
$errorFound = 0;
$lines = ''
}
close dat2;
7 Einträge, 1 Seite |