Output:use Modern::Perl; while (<DATA>) { my ($month, $day, $year, $time, $ampm) = (split ' ')[0 .. 4]; next unless $ampm and $ampm =~ m/AM|PM/i; my $datetime = join ' ', ($month, $day, $year, $time, $ampm); my $xml; my $level; my $orderID; my $orderNumber; while (<DATA>) { if (/([^:]+)\s*:\s*((Authenticate RequestXML)|(Authenticate Re +sponseXML)|(Authorize ResponseXML))\s*:\s*<CardinalMPI>/i){ $level = $1; $xml = $2; } if (m|<OrderId>(\d+)</OrderId>|) { $orderID = $1; } if (m|<OrderNumber>(\d+)</OrderNumber>|) { $orderNumber = $1; } if (m|^</CardinalMPI>$|) { say "$datetime - $level - $xml - $orderNumber - $orderID" +if $xml; last; } } } __DATA__ Nov 16, 2012 5:17:53 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getAuthenticateResponse() FINER: ENTRY Nov 16, 2012 5:17:53 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setAuthenticateRequest() : FINER: ENTRY Nov 16, 2012 5:17:53 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setAuthenticateRequest() : INFO: Authenticate RequestXML : <CardinalMPI> <Version>1.7</Version> <SourceVersion>2.8</SourceVersion> <TransactionPwd>fhsdkjvdxfv</TransactionPwd> <MsgType>cmpi_authenticate</MsgType> <ProcessorId>202</ProcessorId> <Source>JTC</Source> <MerchantId>50515</MerchantId> <TransactionType>HC</TransactionType> <OrderId>8585273913266697</OrderId> <PAResPayload>202|50515|0einiSheyXIFqE4KYrlD|HC</PA +ResPayload> </CardinalMPI> Nov 16, 2012 5:17:53 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setAuthenticateRequest() : FINER: ENTRY Nov 16, 2012 5:17:54 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getAuthenticateResponse() ETC ETC ETC ...
Proper formatting of the output is left as an exercise for the reader.Nov 16, 2012 5:17:53 AM - INFO - Authenticate RequestXML - - 85852739 +13266697 Nov 16, 2012 5:17:53 AM - SEVERE - Authenticate ResponseXML - 5207694 +- 8585273913266697 Nov 16, 2012 5:18:48 AM - INFO - Authorize ResponseXML - 5207694 - 858 +5273913266697
Note that you will get some "Use of uninitialized value ..." warnings. This is considered a feature not a bug! It points you to some records which possibly have incomplete data.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial DeltronicsIn reply to Re: Regexp to read through log file and convert into pipe delimited file?.
by CountZero
in thread Regexp to read through log file and convert into pipe delimited file?.
by laknar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |