How to parse a text file in tcl using separators?
问题 I have a text file of the format 35|46 36|49 37|51 38|22 40|1 39|36 41|4 I have to read the file into an array across the separator "|" where left side will be the key of the array and right side will be the value. I have used the following code foreach {line} [split [read $lFile] \n] { #puts $line foreach {lStr} [split $line |] { if { $lStr!="" } { set lPartNumber [lindex $lStr 0] set lNodeNumber [lindex $lStr 1] set ::capPartsInterConnected::lMapPartNumberToNodeNumber($lPartNumber)