in reply to Not able to capture information
Update:#!/usr/bin/perl -w use strict; my @data = do{local $/ = "\n["; (<DATA>)}; @data = map{ s/\n/ /g; s/\[//g; s/\]/ ==/g; $_}@data; print join "\n", @data; =prints 2012/02/16 00:08:34 == 29 == ERRORMSG unknown error Can't insert into +price table Please check Valueprice.pm line 52. 2012/02/16 00:08:34 == 39 == ERRORMSG Invalid User 2012/02/16 00:14:52 == 105 == ERRORMSG missing conversion rate 2012/02/16 00:14:52 == 29 == ERRORMSG Can't use an undefined value as +a HASH reference at Value.pm line 77. =cut __DATA__ [2012/02/16 00:08:34] [29] ERRORMSG unknown error Can't insert into pr +ice table Please check Valueprice.pm line 52. [2012/02/16 00:08:34] [39] ERRORMSG Invalid User [2012/02/16 00:14:52] [105] ERRORMSG missing conversion rate [2012/02/16 00:14:52] [29] ERRORMSG Can't use an undefined value as a +HASH reference at Value.pm line 77.
My personal advice on parsing very regular program generated things like log files is to keep the regex complexity as low as possible - make it just as complicated as it needs to be and no more. If you are validating "user input" then the complexity level has to be more.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Not able to capture information
by oko1 (Deacon) on Feb 17, 2012 at 07:52 UTC | |
by Marshall (Canon) on Feb 17, 2012 at 09:02 UTC |