Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by parv (Priest)
on Oct 09, 2013 at 19:52 UTC ( #1057618=note: print w/replies, xml ) Need Help??


in reply to Perl Script to extract pattern and redirect to another file

There is no program|code in your listing; it has only the format of files which itself cannot be easily read.

What had you tried? Or, got a plan in terms of pseudo code?

  • Comment on Re: Perl Script to extract pattern and redirect to another file

Replies are listed 'Best First'.
Re^2: Perl Script to extract pattern and redirect to another file
by Raghu1 (Initiate) on Oct 10, 2013 at 10:45 UTC
    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

      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
Node Status?
node history
Node Type: note [id://1057618]
help
Chatterbox?
[Eily]: The best example of that is the TGV, they couldn't decide who would get it so it's in the middle of nowhere halfway between the two
[LanX]: Eily: that rings a bell
[erix]: interesting difference, I suppose they use different data/routes (and shorter seems better, no?)
[LanX]: Montabaur station
[erix]: (I used http://afstandmete n.nl/ )
LanX The stations of Limburg Süd and Montabaur, which are approximately 20 km apart, ...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2017-12-13 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?