Thread lesen von zwei files (6 answers)
Opened by esskar at 2006-06-02 15:29

esskar
 2006-06-02 16:21
#66962 #66962
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
ach so, klar
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
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]);

View full thread lesen von zwei files