Hi All, I am really new to Perl and I have multiple files in my log directory , i need to extract the text from these log files which contains a keyword between "PROC SQL" (This is start point) and "QUIT" (This is end point) and in this block only if "AS KEYWORD" is found then only I want to print it to another file. Below is example
<B> %put %str(NOTE: Mapping columns ...); NOTE: Mapping columns ... 481 proc sql; 482 create table work.INPUT_ACCT_POOL_3 as 483 select 484 Acct_Key, 485 Arrears_Bal_Amt, 486 ARREARS_DAYS, 531 end) as DELQ_STATUS length = 8 532 format = 8. 533 informat = 8. 534 label = 'DELQ_STATUS', 535 Arrears_Start_Date, 536 PERIODENDING, 537 PRODUCT_TYPE_CODE 538 from &SYSLAST SYMBOLGEN: Macro variable SYSLAST resolves to WORK.INPUT_ACCT_POOL_2 + 539 ; NOTE: A CASE expression has no ELSE clause. Cases not accounted for by + the WHEN clauses will result in a missing value for the CASE express +ion. NOTE: Compressing data set WORK.INPUT_ACCT_POOL_3 decreased size by 35 +.05 percent. Compressed is 9043 pages; un-compressed would require 13923 page +s. NOTE: Table WORK.INPUT_ACCT_POOL_3 created, with 5986698 rows and 17 c +olumns. 540 quit; 480 %put %str(NOTE: Mapping columns ...); NOTE: Mapping columns ... 481 proc sql; 482 create table work.INPUT_ACCT_POOL_3 as 483 select 484 Acct_Key, 485 Arrears_Bal_Amt, 486 ARREARS_DAYS, 532 format = 8. 533 informat = 8. 534 label = 'DELQ_STATUS', 535 Arrears_Start_Date, 536 PERIODENDING, 537 PRODUCT_TYPE_CODE 538 from &SYSLAST SYMBOLGEN: Macro variable SYSLAST resolves to WORK.INPUT_ACCT_POOL_2 + 539 ; NOTE: A CASE expression has no ELSE clause. Cases not accounted for by + the WHEN clauses will result in a missing value for the CASE express +ion. NOTE: Compressing data set WORK.INPUT_ACCT_POOL_3 decreased size by 35 +.05 percent. Compressed is 9043 pages; un-compressed would require 13923 page +s. NOTE: Table WORK.INPUT_ACCT_POOL_3 created, with 5986698 rows and 17 c +olumns. 540 quit;
Above text is present in logfile named log1.log and I want to extract only the first block to file named output.txt because it contains as delq_status since I am passing delq_status as variable Anyhelp in this regard is highly appreciated. Thanks

In reply to Extracting a block of text between start and end point by shonurulez

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.