Read a text file into a string:
proc readfile filename { set fp [open $filename] set res [read $fp [file size $filename]] close $fp set res }
Just out of curiosity... would the minimal code below be equivalent, i.e. is the close indeed automatic in this context? -JCW
proc readfile filename { read [open $filename] [file size $filename] }
Touch a file: without modifying the contents, change a file's access time to (now); create it if it doesn't exist, with 0 bytes contents:
proc touch filename { close [open $filename a] } ;# after Don Porter in c.l.t, brought here by RS