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. | |
In reply to Re: Tricky Syslog Parsing
by blue_cowdawg
in thread Tricky Syslog Parsing
by Dru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |