parsing advice

R

Reid Oda

[Note: parts of this message were removed to make it a legal post.]

hi everyone,

i have a file that i want to parse. i'm used to doing this stuff
recursively, and would like to know what the "ruby" style would be. the
file is a series of tests, with the test name at the :start and the test
parameters listed afterwards. here's an example, though the complete file
is much longer:

:start Perf_Video_Integrity
Sample_Rate 44100 :default 48000 88200 96000 176400 192000
:end

:start Perf_Video_Integ_Play
Session_Name :default SessionName
HW_Buffer_Size :default All 64 128 256 512 1024 2048 4096 8192
Play_Time_Minutes :default 20
testType :default SPDIF ADAT
:end

:start Perf_Video_Integ_Rec
Session_Name :default SessionName
HW_Buffer_Size :default All 64 128 256 512 1024 2048 4096 8192
Rec_Time_Minutes :default 20
:end

currently, i have the file in an array of lines. i'd like a function to
find the specified test (i.e. Perf_Video_Integrity), and return an array of
the parameter lines. my specific question is, what is the most elegent way
to build the control structure that extracts the relevant lines?

any advice is appreciated.

-reid
 
M

Michael Fellinger

hi everyone,

i have a file that i want to parse. i'm used to doing this stuff
recursively, and would like to know what the "ruby" style would be. the
file is a series of tests, with the test name at the :start and the test
parameters listed afterwards. here's an example, though the complete file
is much longer:

:start Perf_Video_Integrity
Sample_Rate 44100 :default 48000 88200 96000 176400 192000
:end

:start Perf_Video_Integ_Play
Session_Name :default SessionName
HW_Buffer_Size :default All 64 128 256 512 1024 2048 4096 8192
Play_Time_Minutes :default 20
testType :default SPDIF ADAT
:end

:start Perf_Video_Integ_Rec
Session_Name :default SessionName
HW_Buffer_Size :default All 64 128 256 512 1024 2048 4096 8192
Rec_Time_Minutes :default 20
:end

currently, i have the file in an array of lines. i'd like a function to
find the specified test (i.e. Perf_Video_Integrity), and return an array of
the parameter lines. my specific question is, what is the most elegent way
to build the control structure that extracts the relevant lines?

http://p.ramaze.net/741
Though 'most elegant' is a wide term, especially in Ruby.
Have fun learning!

^ manveru
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,285
Messages
2,571,416
Members
48,108
Latest member
AmeliaAmad

Latest Threads

Top