ropey has asked for the wisdom of the Perl Monks concerning the following question:
Hi There, I have a log file I need to parse and grab all the errors thrown which have been dumped, for instance a log file may look like..
If all the data was read in in one and sucked to a variable go I would just do something like...[2008/10/14 10:57:18] [55] DEBUG Austin::API::vendor_api - Initialisin +g the API Galileo [2008/10/14 10:57:18] [41] DEBUG Austin::Suppliers::Common::Location:: +init - Setting Up Generic Locations [2008/10/14 11:15:22] [147] DEBUG Austin::Controller::default - $VAR1 += { 'Errors' => [ { 'ID' => 'noRates', 'Error' => 'No Rates for given dates/times', 'object' => '/var/website/modules/Austin/CB/ +Search.pm', 'Location' => undef, 'line' => 371 }, ] }; [2008/10/14 10:57:18] [245] DEBUG Austin::XV::Trip::set_time_zone - Ch +ecking timezone with agent UK [2008/10/14 10:57:18] [247] DEBUG Austin::XV::Trip::set_time_zone - Se +tting timezone to Europe/London [2008/10/14 11:15:22] [2008/10/14 11:15:22] [147] DEBUG Austin::Controller::default - $VAR1 += { 'Errors' => [ { 'ID' => 'noRates', 'Error' => 'No Rates for given dates/times', 'object' => '/var/website/modules/Austin/CB/ +Search.pm', 'Location' => undef, 'line' => 371 }, ] }; [2008/10/14 11:15:22]
while($data =~ /'Errors' => \[([^\]]+)/sgm) { my $match = qq|\$ref = [$1];|; my $ref; $ref = eval {$match}; print Dumper($ref); }
However as you would expect the file is going to be pretty huge and reading it in one hit isn't a option, and obviously I dont want that. I guess i could change the $/ = ';'; and iterate that way.... hmmmm any better ideas ?
Also be nice if I could pipe to it also so tail -f <LOG> | log_grepper.pl..
I look forward to hearing your improvements !
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Buffered read and matching
by jethro (Monsignor) on Oct 15, 2008 at 11:05 UTC | |
by Perlbotics (Archbishop) on Oct 15, 2008 at 12:35 UTC | |
by jethro (Monsignor) on Oct 15, 2008 at 13:41 UTC | |
Re: Buffered read and matching
by BrowserUk (Patriarch) on Oct 15, 2008 at 11:28 UTC | |
Re: Buffered read and matching
by Anonymous Monk on Oct 15, 2008 at 11:03 UTC | |
Re: Buffered read and matching
by Anonymous Monk on Oct 15, 2008 at 11:20 UTC | |
Re: Buffered read and matching
by Wiggins (Hermit) on Oct 15, 2008 at 14:10 UTC | |
Re: Buffered read and matching
by educated_foo (Vicar) on Oct 15, 2008 at 16:47 UTC |