Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Perl Script to extract pattern and redirect to another file

by Raghu1 (Initiate)
on Oct 10, 2013 at 10:45 UTC ( [id://1057716]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl Script to extract pattern and redirect to another file
in thread Perl Script to extract pattern and redirect to another file

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

Replies are listed 'Best First'.
Re^3: Perl Script to extract pattern and redirect to another file
by Jenda (Abbot) on Oct 10, 2013 at 15:48 UTC

    If you can't be bothered to format your post so that we can read it, why do you think we will be bothered to solve your problem for you?

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

      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: XA-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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1057716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-19 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found