From: Michael Fellinger Date: 2008-03-06T11:40:26+09:00 Subject: Re: parsing advice On Thu, Mar 6, 2008 at 9:35 AM, Reid Oda wrote: > 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