svijay has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, Im newbie to perl. I need a help in extracting below information from text file and output to csv file.

INPUT IN TEXT FILE:

Totals:

RAM G_RAM ROM NVM Reu 0 0 0 0 App 0 0 0 0 Lev 0 0 0 0 New 6894 0 7048107 0 total 6894 0 7048107 0

In text file more number of such tables are there. I need to extract only table under Totals:

OUTPUT TO CSV FILE

RAM,G_RAM,ROM,NVM 6894,0,7048107,0

Any help would be appreciated

Replies are listed 'Best First'.
Re: Extract information from text file
by toolic (Bishop) on Feb 17, 2015 at 15:12 UTC
    • Read perlintro.
    • Write some code.
    • Post back with specific questions about the code you wrote.

      To expand on point #2

      • Think about how you would do it without a computer.
      • Consider how you would instruct the worlds most clueless math savant to do it for you.
      • Have the computer do it the same way.
Re: Extract information from text file
by vinoth.ree (Monsignor) on Feb 17, 2015 at 17:29 UTC
Re: Extract information from text file
by NetWallah (Canon) on Feb 18, 2015 at 05:15 UTC
    If you care to learn, please research. If not - try to use this, hopefully, to learn
    perl -ane 'm/^total/ ? shift @F:$.==1 or next; print join(",",@F),"\n" +' INPUT-FILE-NAME.TXT
    Now that you have a solution, hopefully, it generates interest, and specific questions you can ask here.

            "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams