From: Ezra Zygmuntowicz Date: 2005-12-07T07:19:44+09:00 Subject: Re: [Newbie] Variable score On Dec 6, 2005, at 2:12 PM, 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 = ..... > var1 = '' #initialize to striung or whatever else you expect the result of the match to be. var2 = '' > 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, > > > HTH- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com