Posted to tcl by bairui at Wed Dec 16 22:03:18 GMT 2015view raw

  1. # aspect's lmap & -inline approach:
  2.  
  3. set mydict1 [dict create {*}[concat {*}[lmap {_ k v} [regexp -all -inline {(\w+)=((?:.(?!\w+=))*)} [read [open data]]] {list $k $v}]]]
  4.  
  5.  
  6. # not using -inline
  7.  
  8. set mydict2 [dict create {*}[concat {*}[regsub -all -expanded {(\w+)=((.(?!\w+=))*)} [read [open data]] [list {\1 {\2}}]]]]
  9.