I have a code
require 'rubygems'
conf_array = []
File.open("C:/My Program Files/readme.txt", "r").each_line do |line|
conf_array << line.chop.split("\t")
end
a = conf_array.index{|s| s.include?("server =")}
puts a
and it doesn't display the index of item. Why?
Array looks like
conf_array = [
["# This file can be used to override the default puppet settings."],
["# See the following links for more details on what settings are available:"],
["# - docs.puppetlabs.com/puppet/latest/reference/config_important_settings.html"],
["# - docs.puppetlabs.com/puppet/latest/reference/config_about_settings.html"],
["# - docs.puppetlabs.com/puppet/latest/reference/config_file_main.html"],
["# - docs.puppetlabs.com/references/latest/configuration.html"], ["[main]"],
["server = server.net.pl"],
["splay = true"],
["splaylimit = 1h"],
["wiatforcert = 30m"],
["http_connect_timeout = 2m"],
["http_read_timeout = 30m"],
["runinterval = 6h"],
["waitforcert = 30m"]
]
And next how to display that item? I mean a = conf_array[#{a}] says syntax error.
I tried also
new_array = []
new_array = conf_array.select! {|s| s.include?("server =")}
and it again does't display found item. Any suggestion?