ACiD has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Variable Length Parsing
by jeffa (Bishop) on Jun 08, 2003 at 21:00 UTC | |
by ACiD (Novice) on Jun 08, 2003 at 21:51 UTC | |
by jeffa (Bishop) on Jun 09, 2003 at 00:58 UTC | |
|
Re: Variable Length Parsing
by tcf22 (Priest) on Jun 08, 2003 at 20:40 UTC | |
|
Re: Variable Length Parsing
by CombatSquirrel (Hermit) on Jun 08, 2003 at 20:56 UTC | |
|
Re: Variable Length Parsing
by TomDLux (Vicar) on Jun 08, 2003 at 20:40 UTC | |
by Aristotle (Chancellor) on Jun 08, 2003 at 23:49 UTC | |
|
Re: Variable Length Parsing
by pzbagel (Chaplain) on Jun 08, 2003 at 20:44 UTC | |
|
Re: Variable Length Parsing
by tos (Deacon) on Jun 08, 2003 at 20:48 UTC |