From: Matthew Desmarais Date: 2005-12-07T07:31:04+09:00 Subject: Re: [Newbie] Variable score vnpenguin@gmail.com wrote: >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, > > Are you certain that you've matched regexp1 before you've matched regexp2? Regards, Matthew