From: Brian Candler Date: 2012-08-16T05:49:24+09:00 Subject: Re: string processing Fosiul Alam wrote in post #1072480: > but there is a problem , I have modified this as bellow > > DATA.each do |line| > if line =~ /^Success - new device-id: \((\d+)\)/ > device_id = $1 > end > end > > puts #{device_id} > > and this does not return anything .. > > how can i use the value outside of the loop ?? put: device_id = nil before the loop. It's one of the ruby scoping rules that if you first assign to a variable inside a block, it disappears at the end of that block. -- Posted via http://www.ruby-forum.com/.