in reply to Tricky Syslog Parsing
Having been faced with solving a very similar problem not that long ago let me pass along one lesson that I learned: Create regexs using qq() and test each one one at a time.
Caveat:All the following code has not been tested
Looking at the examples you ahve provided here are a few thoughts.
Now you can take each of the regexs that make up the big regex and test them one at a time and see if they work.my $dtg=qq@\d+\-\d+\-\d+\s\d+:\d+:\d+@; # Date time group my $logtype=qw@Local\d\.[Error|Critical]@; # Log type my $ipaddr=qw@\d+\.\d+\.\d+\.\d+@; # IP Address my $odtg=qq@[A-Za-z]{3}\s\d+\s\d+\s\d+:\d+:\d+:@; my $select=qq@%FW\-\d+\-\d+@; # FW or PIX? my $match_line=qq@$dtg\s+$logtype\s+$ipaddr\s+$otg\s+$select@;
Two other comments:
| Peter L. Berghold -- Unix Professional Peter at Berghold dot Net | |
| Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice. | |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Tricky Syslog Parsing
by Dru (Hermit) on Jan 13, 2004 at 19:21 UTC | |
by elwarren (Priest) on Jan 13, 2004 at 21:39 UTC |