T
Thomas Luedeke
I'm trying to do something that I think would be pretty trivial. I've
read in an external file as an array. I want to parse the array of
lines, and set a line number as a variable if the line matches a certain
pattern. The file is rather long, so I want to break out of the loop
once I've made the match.
I've tried this a number of different ways, and they either don't work,
or I get some JumpError (which is incomprehensible to my newbie mind).
I'm still deeply in the "suck period" of learning Ruby (and
transitioning from O-O Fortran 95 and UNIX scripting), so I'm struggling
quite a bit.
I'm running Ruby 1.8.6 through Eclipse.
Where I'm at is the following (and this is just the latest in a series
of varieties trying to make the stupid thing work):
============================
inputFile = File.open( "filename","r" )
inputArray = inputFile.readlines
counts = 1
xcob3cArray.each catch
breakout) do |line|
line_number = counts
throw
breakout) "$counts" if ( line.lstrip =~ /^(11))/ )
counts = counts + 1
end
line_number = $counts
============================
Any help would be greatly appreciated!!
read in an external file as an array. I want to parse the array of
lines, and set a line number as a variable if the line matches a certain
pattern. The file is rather long, so I want to break out of the loop
once I've made the match.
I've tried this a number of different ways, and they either don't work,
or I get some JumpError (which is incomprehensible to my newbie mind).
I'm still deeply in the "suck period" of learning Ruby (and
transitioning from O-O Fortran 95 and UNIX scripting), so I'm struggling
quite a bit.
I'm running Ruby 1.8.6 through Eclipse.
Where I'm at is the following (and this is just the latest in a series
of varieties trying to make the stupid thing work):
============================
inputFile = File.open( "filename","r" )
inputArray = inputFile.readlines
counts = 1
xcob3cArray.each catch
line_number = counts
throw
counts = counts + 1
end
line_number = $counts
============================
Any help would be greatly appreciated!!