pairs.each do |name, value|
puts “e#{name} = #{value}”
end
The XML to array code kind of sucks, in the next version of scRUBYt! you
will be able to output the result directly to a hash (or CSV or YAML or
some other, more friendly format for such a task).
file_in = File.read(“C:/WIKI_CE/index_msg.htm”)
File.open(“C:/WIKI_CE/enumWmMsg.h”, “w”) do |file_out|
file_in.scan(REGEX) do
file_out.puts $1, $2, $3, $4, $5
end
end
end
Notes:
we_use_snake_case_for_variable_names
Use File.open with block to automatically close the file
You’ll have the values in $1…$5
It seems you are inconsistent - in the first example you chose the
second line, in the other the fourth one.
In any case, Peter’s approach will be easier, and more stable.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.