Hi, I am really sorry for inconvenience. I tried uploading the data in correct format, while uploading by default its merging the content. Here is the code I am trying out : In this code when I run the script, It will display the Group name which starts with X.
my $str = ""; open (FD, "<", "CSD.txt"); my @lines = <FD>; close FD; foreach (@lines) { if(/GROUP NAME: X[A-Z]../) { print STDOUT $_; $str= $str.$_; open (NW, ">", "RES.txt"); print NW $str; close NW; } }
My requirement is to get the List name which has Group name starts with X. I need to extract Transactions code which comes under Group name as well. The output should be
List name: CT08LIST GROUP XCT08L1 04.290 17:05 Trasactions ROUP NAME: XCT08L1 ---------- MAPSETS: AGCEM1 AGHEM1 AGMMM1 AGONM1 AGPEM1 + AGPUM1 AGREM1 AGRUM1 AGSEM1 AGSUM1 AGZ1M1 AGZ2M1 AGZ3M1 AGZ4M1 + AGZ5M1 TRANSACTIONS: ACBA ACBE ACBL ACBR ACBU + AGMM AGSU AGTO AST5 AST7 AST9 AXTO BAC1 BCA1 + BCA2 BCA3 BCA4 BCA5 BD11 BE1A BE44 BM16 BM17 + BM6A BSL3 BSVL BS09 BS11 BS12 BS13 BS14 BTM2 + BWR2 HMI8 IBVS IM01 IM02 IM03 IM07 IM18 IM21 + IM25 MSOD NPS2 STP1 XB01 XB02 XB03 XB04 XB05 + XB06 XB07 XB08 XB10 XB11 XB12 GROUP NAME: XCT09L1 ----------
I can send the input file wherein you can have a look on the file. Kindly let me know your mail id so that I can send the input file/exact requirement

In reply to Re^2: Perl Script to extract pattern and redirect to another file by Raghu1
in thread Perl Script to extract pattern and redirect to another file by Raghu1

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.