Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Im trying to grep a set of strings to find each record in a log file and grep the fields for the corresponding string. the scenario is to find the string and read the above line for date and also grep a field OrderID from the below lines for each search string.The search strings are "Authenticate RequestXML", "Authenticate ResponseXML", "Authorize RequestXML", "Authorize ResponseXML"

Below is the sample log file.
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&#124;50515&#124;0einiSheyXIFqE4KYrlD&#124;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() SEVERE: Authenticate ResponseXML : <CardinalMPI> <MerchantData></MerchantData> <ShippingAmount>1762</ShippingAmount> <MerchantReferenceNumber></MerchantReferenceNumber> <ErrorNo>0</ErrorNo> <CustomData></CustomData> <TransactionId>0einiSheyXIFqE4KYrlD</TransactionId> <ErrorDesc></ErrorDesc> <OrderNumber>5207694</OrderNumber> <ShippingMethod></ShippingMethod> <CardType>Visa</CardType> <PAResStatus>Y</PAResStatus> <ProcessorOrderNumber></ProcessorOrderNumber> <TaxAmount>543</TaxAmount> <PaymentType>CC</PaymentType> <PaymentProcessorOrderNumber></PaymentProcessorOrderNumber> <NotificationId>CCCDFHFCIGIILHEIT32Z89NPWO5S8A</NotificationId> <ActionCode>AUTHORIZE</ActionCode> <ReasonDesc></ReasonDesc> <CardLastFour>6061</CardLastFour> <Amount>8303</Amount> <AuthorizationCode></AuthorizationCode> <ReasonCode></ReasonCode> <OrderId>8585273913266697</OrderId> <SignatureVerification>Y</SignatureVerification> </CardinalMPI> Nov 16, 2012 5:17:54 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getAuthenticateResponse() SEVERE: : Authentication Success for for ORDER : 5207694 Nov 16, 2012 5:17:54 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getAuthenticateResponse() FINER: ENTRY Nov 16, 2012 5:17:56 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean checkHealth() INFO: checkHealth() Nov 16, 2012 5:17:56 AM com.sitapp01.commerce.payments.plugin.cybersou +rce.bean.AYCyberSourcePaymentsPluginBean checkHealth() INFO: checkHealth() Nov 16, 2012 5:17:56 AM com.sitapp01.commerce.payments.plugin.giftcard +.bean.AYGiftCardPaymentsPluginBean checkHealth() INFO: checkHealth() Nov 16, 2012 5:18:44 AM com.sitapp01.commerce.checkout.commands.OrderR +eviewCmdImpl performExecute INFO: OrderReview submmitted : Nov 16, 2012 5:18:48 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean approve(pluginContext, approveTran +saction, retry )false FINER: ENTRY Nov 16, 2012 5:18:48 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean setAuthorizeRequests FINER: ENTRY Nov 16, 2012 5:18:48 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean setAuthorizeRequests INFO: Authorize RequestXML : <CardinalMPI> <Version>1.7</Version> <SourceVersion>2.8</SourceVersion> <TransactionPwd>dfdskfjdskfjc</TransactionPwd> <MsgType>cmpi_authorize</MsgType> <ProcessorId>202</ProcessorId> <Source>JTC</Source> <Amount>8303</Amount> <CurrencyCode>840</CurrencyCode> <MerchantId>50515</MerchantId> <MerchantData>50515</MerchantData> <TransactionType>HC</TransactionType> <OrderId>8585273913266697</OrderId> <OrderDescription>Test Desc</OrderDescription> </CardinalMPI> Nov 16, 2012 5:18:48 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean setAuthorizeRequests FINER: EXIT Nov 16, 2012 5:18:48 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean getAuthorizeResponse() : FINER: ENTRY Nov 16, 2012 5:18:52 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean getAuthorizeResponse() : INFO: Authorize ResponseXML : <CardinalMPI> <AuthorizationCode>016618</AuthorizationCode> <StatusCode>Y</StatusCode> <ReasonCode></ReasonCode> <ErrorDesc></ErrorDesc> <ProcessorRawResponse_CC_Authorize>AuthRecord=0110322001810E900002 +000000000000008303111603185000842700015912000000000001593234595939443 +457484D4E303136363138303030323834363038300001590083004831345730303233 +323134303733303039393250465244202030303030303030303030303030303030303 +030303030303000183232415050524F56414C20202020202020200003343820000656 +4943524320&ProcessorResponse=00&ReconciliationId=Y24YY9D4WHMN&Request +Id=3530647306590176056425</ProcessorRawResponse_CC_Authorize> <MerchantReferenceNumber></MerchantReferenceNumber> <ErrorNo>0</ErrorNo> <ProcessorRawResponse>interface=OK&lp_execute_status=PENDING&ACCT_ +NUM=XXXXXXXXXXXX6061&ACT_CD=OA&AMT=8303&CARD_SEC_IND_CD=1&CUST_ADDR1= +2607+Whittier+Place&CUST_CITY=Hephzibah&CUST_CNTRY_CD=USA&CUST_EMAIL= +eugenec30%40cs.com&CUST_FNAME=William&CUST_HOME_PHONE=7067937577&CUST +_ID=130668178&CUST_LNAME=Cutler&CUST_POSTAL_CD=308156120&CUST_STPR_CD +=GA&CUST_TYPE_CD=B&D_ACCT_NUM=e7daea2735ed4296363388954468550b46e026d +f&DIV_NUM=cardinal&FRAUD_REC_ID=000151010001GB920121116062534707&FRAU +D_RSP_CD=0100&FRAUD_STAT_CD=ACCEPT&FRAUD_USE_CD=C&MOP_TYPE_CD=VI&ORD_ +ID=5207694&PROC_CD=EBT&REQ_ID=780078748245&REQ_TYPE_CD=E&RSP_AVS_CD=Y +&RSP_CD=00&RSP_SEC_CD=P&S_ACCT_NUM=MDEyOI8ptWYFiREeP37gqZdSL9SRlRumMJ +LuEsAV5sT5eDKsnOkEx1VOVTLaPyTdr%2FFxd4%2BBOD1fceoDgwv4kA0q1Xd7GulPwgC +KMqR1sTcvKKhC1DYSJVS5Sman9R0GyFQr%2F3QBHhFA%2BGrLq7GbjgBbNSMs8dq%2BeC +49pIwIlpEJgwtM&S_CARD_EXP_DT=MDEyOGb4%2BEILRMAysKxbyGGm6%2BscLClDCHB3 +rTZ4wlRhwdKoNxLFLo%2BbOfyEgWuA80qbnn0vyKk1tl5Z37HENlh1CmW2cxqjxknooiX +JcdDMwQxlXievOvmSBGMh6XxP0W2cfaCydkI9tsuoqvOn949iCJv4aBDIAy0yDFcGBicz +UCYI&S_KEY_ID=129&STAT_CD=PENDING</ProcessorRawResponse> <CardCodeResult>P</CardCodeResult> <TransactionId>un7Y71kayZdgiVCsak86</TransactionId> <OrderNumber>5207694</OrderNumber> <ReasonDesc></ReasonDesc> <MerchantData>50515</MerchantData> <AVSResult>P</AVSResult> <OrderId>8585273913266697</OrderId> <ProcessorOrderNumber>3530647306590176056425</ProcessorOrderNumber +> </CardinalMPI> Nov 16, 2012 5:18:52 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean getRequestAuthCode SEVERE: : Authorization Code for Order : 5207694 Is 780078748245 Nov 16, 2012 5:18:52 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean getRedStatus() SEVERE: : RED status for Order : 5207694 Is ACCEPT Nov 16, 2012 5:18:52 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean getAuthorizeResponse() : SEVERE: : Payment Success for for ORDER : 5207694 Nov 16, 2012 5:18:52 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean getAuthorizeResponse() : FINER: EXIT Nov 16, 2012 5:18:52 AM com.sitapp01.commerce.payments.plugin.centinel +.bean.AYCentinelPaymentsPluginBean approve(pluginContext, approveTran +saction, retry )false FINER: EXIT Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setCentinelRequest FINER: ENTRY Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setCommodityCodeAndShipId: SEVERE: Entry Point:orders ID 5210188 Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setCommodityCodeAndShipId SEVERE: Attribute Id ::219055 Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setMFPartNumber: SEVERE: Entry Point:orders ID 5210188 Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setItemDesc: SEVERE: Entry Point:orders ID 5210188 Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setItemDesc: SEVERE: Item_Desc_Wilson Championship Nylon Shuttlecocks 6-Pack Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setItemShippingNumber: SEVERE: Entry Point:orders ID 5210188 Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getReDShipMethod FINER: ENTRY Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getReDShipMethod FINE: shippingModeId: 10551 Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getReDShipMethod FINE: Shipping Code: UPS Ground Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til getReDShipMethod FINE: returnReDShipMethod: C Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setItemShippingNumber FINE: Attribute Id ::219051 Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setItemShippingNumber SEVERE: Item_Shipping_Number_:S&L Nov 16, 2012 5:27:33 AM com.sitapp01.commerce.CentinelUtil.AYCentinelU +til setCentinelRequest

the expected output would be like below.

Column Names. Start_Date|Message|Request_Type|OrderNumber|OrderID Nov 16, 2012 5:17:53 AM|INFO|Authenticate RequestXML||8585273913266697 Nov 16, 2012 5:17:53 AM|SEVERE|Authenticate ResponseXML|5207694|858527 +3913266697 Nov 16, 2012 5:18:48 AM|INFO|Authorize RequestXML||8585273913266697 Nov 16, 2012 5:18:52 AM|INFO|Authorize ResponseXML|5207694|85852739132 +66697
I need to use perl script to acheive this scenario. Any help will be greatly appreciated.

In reply to Regexp to read through log file and convert into pipe delimited file?. by laknar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (12)
    As of 2014-10-31 13:06 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (217 votes), past polls