我有一个从TCL脚本输出的文件,它有一个TCL语法的数组,如下所示。
set data(item1) {
xyz {
a { one two three 1 2 3}
b { three one two 3 2 4}
}
lmn {
z { "something" 1 2 3}
d { "samething" 3 2 4}
}
};
set data(item2) {
xyz {
ss { 100 }
sd { "sdss" 200 300}
}
lmn {
ee { "xdf" 1 "2dsd" 3}
pp { "dd" "fsdf" 3 2 4}
}
};
现在我需要在Ruby程序中读取这个文件并在开始使用所需数据之前将它们构建为Hash of Hashes,类似于下面的内容:
data = {
'item1' => {
'xyz' => {
'a' => %w{one two three 1 2 3},
'b' => %w{three one two 3 2 4}
},
'lmn' => {
'z' => %w{something 1 2 3},
'd' => %w{samething 3 2 4}
}
},
'item2' => {
'xyz' => {
'ss' => %w{100 },
'sd' => %w{sdss 200 300}
},
'lmn' => {
'ee' => %w{xdf 1 2dsd 3},
'pp' => %w{dd fsdf 3 2 4}
}
}
}
是否有可用于此目的的Ruby实用程序或方法?
提前感谢您的支持。