V
vnpenguin
Hi all,
I'm newbie to Ruby. I'm trying to write a small script to parse a text
file
#-----------------------------------------------------------------------------------
regexp1 = ....
regexp2 = .....
data.each do |line|
if regexp1.match(line) then
var1 = $~[1]
var2 = $~[2]
end
if regexp2.match(line) then
var3 = $~[1]
print "#{var1} #{var2} #{var3}\n"
end
end
#-------------------------------------------------------------------------------------
I can not access to var1 & var2 in 2nd if .... then ... end control.
Any idea for help please,
Thank you in advance,
I'm newbie to Ruby. I'm trying to write a small script to parse a text
file
#-----------------------------------------------------------------------------------
regexp1 = ....
regexp2 = .....
data.each do |line|
if regexp1.match(line) then
var1 = $~[1]
var2 = $~[2]
end
if regexp2.match(line) then
var3 = $~[1]
print "#{var1} #{var2} #{var3}\n"
end
end
#-------------------------------------------------------------------------------------
I can not access to var1 & var2 in 2nd if .... then ... end control.
Any idea for help please,
Thank you in advance,