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

Hi Folks,
I have the following data:
name(DAWSON) { Team 1 { Weight: 12.00; } vin(Y) { Status:Active; time { event: cancer; amount_raised { index1( 1, 2, 3, 4); index2(1, 11, 13,16); points(1,2,3,4, \ 5,6,7,8, \ 10,19,20,0, \ 0, 0, 8, 6 \ ); } } } }

From the above data, I want to print:
DAWSON:vin(Y):Status:Active:time:event: cancer:amount_raised:index1(1, +2,3,4):index2(1,11,13,16) ---> points(1,2,3,4,5,6,7,8,10,19,20,0,0,0, +8,6)

Any help from the monks is appreciated.
--Jessica.

Replies are listed 'Best First'.
Re: Parsing multiple lines into a single line
by ysth (Canon) on Jan 09, 2008 at 01:23 UTC
      After getting the specs per Ysth, do something like below
      { local $/ ; while (<DATA>) { /^name\(([^)]+)\).+\{.+(\w{4}).+(\d).+/sg; print "$3:$2:$1\n"; } } __DATA__ name(DAWSON) { Team 1
      Hi,
      When ever  "Weight: 12.00" occurs in the data, that entire block is discarded. Hence, we discard
      Team 1 { Weight: 12.00; }
      Sorry for not being clear earlier. Appreciate your help.
      --Jessica
      Hi Ysth,
      Whenever we have  Weight: 12.00;
      I need to discard the block in which Weight: 12:00; is present. Hence
      Team 1 { Weight: 12.00; }

      is discarded.
      The  ---> always points right before  points in the data.
      --Jessica
Re: Parsing multiple lines into a single line
by apl (Monsignor) on Jan 09, 2008 at 02:08 UTC
    Could you show us the code you've written? Then we could help you take the next step...
      Hi,
      I am very new to Perl, that is why I need help :)
      Right now, all I am doing is using chomp and writing to tempfile and reusing chomp and again writing to temp files...and process the data this way...which I assume is not efficient.
      --Jessica.