I have a file where I search for specific lines, like this:
<ClCompile Include="..\..\..\Source\fileA.c" />
<ClCompile Include="..\..\..\Tests\fileB.c" />
In my script I can find this lines and extract only the path string between the double qoutes . When I find them, I save it to an array (which I use later in my code). It looks like this:
source_path_array = []
File.open(file_name) do |f|
f.each_line {|line|
if line =~ /<ClCompile Include="..\\/
source_path = line.scan(/".*.c"/)
###### Add path to array ######
source_path_array << source_path
end
}
end
So far, everything OK. Later in my script I output the array within an other file to a line "Source Files":
f.puts "Source Files= #{source_path_array.flatten.join(" ")}"
The result is than like this:
Source Files= "..\..\..\Source\fileA.c" "..\..\..\Tests\fileB.c"
I would like to have the output in this form:
Source Files=..\..\..\Source\fileA.c
Source Files=..\..\..\Tests\fileB.c
As you can see, each path in an separate line with the string "Source Files" before and also without double quotes. Any idea? Maybe my concept with the array is also not the best.