From: "Jan E." Date: 2012-09-10T00:24:12+09:00 Subject: Re: Match an ARray Element by if sharmin malik wrote in post #1075208: >> >> res2 =~ /^test1$/ > > its works fine > sname << res1 > sname.each { |item| > if (item =~ /#{name}/) > puts "its there" > else "No tiem" > end > This makes no sense. Again: Why do you even need an array when you only got one string? At least that's the case in the original code. If I understand you correctly, ssh.exec!(@cmd) returns a string that may have multiple lines. To check if one of these lines is "test1", simply use res2 = ssh.exec! @cmd if res2 =~ /^test1$/ puts "its has value" else puts "its does not have value" end The "sname" array has absolutely no purpose (unless you want to do something different than your original code suggests). >> What's the error message? > array.rb:5: wrong argument type Symbol (expected Proc) (TypeError) Then I guess you use an obsolete Ruby version. Maybe 1.8.6? If that's the case, update your Ruby. -- Posted via http://www.ruby-forum.com/.