develooper Front page | perl.beginners | Postings from December 2011

parsing data

Thread Next
From:
Chris Stinemetz
Date:
December 20, 2011 17:16
Subject:
parsing data
Message ID:
CA+HbpzhoCfH+ehcH0+b82wuvgxBXQ46_6nG0zJLeg+2QazeJqA@mail.gmail.com
Hello list,

I am having some trouble coming up with a solution for what I am
trying to accomplish.

Any advice is greatly appreciated.

A sample of the data I would like to parse is below:

I am trying to build a table like structure where the string to the
left of the "=" sign is the header and the value to the right of the
"=" is the data value. I want to make sure to account for null value
(no value to the right of the "=")

Each new group begins with >csno and ends with a new line. I am
thinking that I am going to need to create a hash and possibly
incorporated regex, but I am not real sure how to begin this task.

I am trying to obtain the following format with the input data:

*** desired output ***
csno	rfpi	vrp0	vrp1	trl	line	low	high
1	1	3423000	3423000	1700000			5
1	2	3423000	3423000	1700000			5
1	3	3423000	3423000	1700000			5


*** input ***
>csno=1
rfpi=1
vrp0=3423000
vrp1=3423000
trl=1700000
line=
low=
high=5

>csno=1
rfpi=2
vrp0=3423000
vrp1=3423000
trl=1700000
line=
low=
high=5

>csno=1
rfpi=3
vrp0=3423000
vrp1=3423000
trl=1700000
line=
low=
high=5

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About