Been browsing the monk site for awhile now...GREAT HELP! Thanks.
I am all new to Perl, so any help is greatly appreciated. I have several syslog files that I am parsing. Others are done because the fields are static, however, this one is killing me. I open the file and in a while loop, parse each line (till eof). Each line looks like the following (from snort ids):
May 16 11:17:12 system app: [id:id:id] Message [Class] [Priority:] {TCP} 111.1.1.64:1863 -> 222.2.2.155:55527
Here's what I have so far (from trying this and that):
if ($line =~ m/^(\w{3}) \s+ (\d+) \s (\d+\:\d+\:\d+) \s (\S+)\s snort [\[(\d+\:\d+\:\d+)\]]*\:\s+(.+)/ox)
$1 through $4 come out OK, but then $5 scoops up till end of line. (please forgive the poor code)
My problem is I cannot match the variable length field between [id:id:id] and {TCP}. This area will be variable based on {ICMP}, {TCP/UDP}, or error, which I will if statement out when I get this step resolved.
Any help is appreciated.
In reply to Variable Length Parsing by ACiD
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |