in reply to Not able to capture information
This modification to your code:
use strict; use warnings; while(<DATA>) { chomp($_); if ($_ =~ m/\[(\d{4}\/\d{2}\/\d{2}\s+\d{2}\:\d{2}\:\d{2})\]\s+\[(\ +d{1,3})\]\s+ERRORMSG\s+(.*)/) { my $date = $1; my $err_no = $2; my $err_msg = $3; if ($. > 1) { print qq{\n}; } print "$date === $err_no === $err_msg"; } else { print qq{ $_}; } } print qq{\n};
produces this output:
ken@ganymede: ~/tmp $ pm_multiline_regex.pl 2012/02/16 00:08:34 === 29 === unknown error Can't insert into price +table Please check Valueprice.pm line 52. 2012/02/16 00:08:34 === 39 === Invalid User 2012/02/16 00:14:52 === 105 === missing conversion rate 2012/02/16 00:14:52 === 29 === Can't use an undefined value as a HASH + reference at Value.pm line 77. ken@ganymede: ~/tmp $
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Not able to capture information
by Don Coyote (Hermit) on Feb 17, 2012 at 10:10 UTC | |
by kcott (Archbishop) on Feb 17, 2012 at 10:39 UTC |