puts command is used to write to an open file.
puts $filename "text to write"
A simple example for writing to a file is shown below.
#!/usr/bin/tclsh
set fp [open "input.txt" w+]
puts $fp "test"
close $fp
Reading a File
set file_data [read $fp]
#!/usr/bin/tclsh
set fp [open "input.txt" w+]
puts $fp "test"
close $fp
set fp [open "input.txt" r]
set file_data [read $fp]
puts $file_data
close $fp
r,w a,r+,w+,a+
The "regexp" command is4 used to match a regular
expression in Tcl. A regular expression is a sequence of
characters that contains a search pattern. It consists of
multiple rules and the following table explains these rules
and corresponding use.