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
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @entries;
my @filtered;
my $event = {};
while (<>) {
chomp;
unless ($_) {
push @entries, $event if keys %$event;
$event = {};
next;
}
if (/^(\w+):\s?(.+)$/) {
$event->{$1} = $2;
} else {
$event->{msg_text} .= $_."\n";
}
}
@filtered = grep { $_->{Severity} =~ /Error/ } @entries;
die Dumper \@filtered;
$ perl skript.pl logfile.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @entries;
{
local $/ = "\n\n";
open(my $fh,'<',$ARGV[0]) or die $!;
while(my $entry = <$fh>){
push(@entries,$entry) if($entry =~ /Severity: Error/s);
}
close $fh;
}
print Dumper(\@entries);
local $/ = "\n\n";
7 Einträge, 1 Seite |