--- a/postgrep Wed Dec 02 07:47:31 2009 +0100
+++ b/postgrep Wed Dec 02 07:48:00 2009 +0100
@@ -16,20 +16,21 @@
while (<>) {
- if (!/^(?<date>.{15})
+ if (
+ !/^(?<date>.{15})
\s(?<host>\S+)
\s(?<service>\S+):
\s(?<pfid>[[:xdigit:]]+):
- \s(?<rest>.*)/x) {
-
- print "$_\n" if /$pattern/i;
- next;
-
+ \s(?<rest>.*)/x
+ )
+ {
+ print "$_\n" if /$pattern/i;
+ next;
}
my $ts = str2time($+{date});
- push @{$msglog{$+{pfid}}}, $_;
+ push @{ $msglog{ $+{pfid} } }, $_;
# a "removed" line does not have to be the last
# line for a message, sometimes the qmgr logs a bit
@@ -37,24 +38,23 @@
# thus remember the "removed" ID we've seen
if ($+{rest} eq "removed") {
- push @{$removed{$ts}}, $+{pfid};
+ push @{ $removed{$ts} }, $+{pfid};
}
# and count all IDs with "removed" older than 60 seconds as
# completed
foreach (grep { ($ts - $_) > 60 } keys %removed) {
- foreach (@{delete $removed{$_}}) {
- print @{delete $msglog{$_}}, "\n"
- if /$pattern/i ~~ @{$msglog{$_}};
- }
+ foreach (@{ delete $removed{$_} }) {
+ print @{ delete $msglog{$_} }, "\n"
+ if /$pattern/i ~~ @{ $msglog{$_} };
+ }
}
-
}
-# the rest
+# the rest
foreach (values %msglog) {
print join @$_, "\n"
- if /$pattern/ ~~ @{$msglog{$_}};
+ if /$pattern/ ~~ @{ $msglog{$_} };
}