vnpenguin / gmail.com schrieb:
> #-----------------------------------------------------------------------------------
> 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,

Do regexp1 and regexp2 match on the same line of data? Or could it be 
that regexp1 matches first and then regexp2 on a following line? If so, 
you have to create var1 and var2 outside of the block, as Ezra has 
shown. Otherwise they are (re)initialized each time the block is executed.

Regards,
Pit