<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.twig.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Tcl_%3A_read_a_file</id>
		<title>Tcl : read a file - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.twig.es/index.php?action=history&amp;feed=atom&amp;title=Tcl_%3A_read_a_file"/>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Tcl_:_read_a_file&amp;action=history"/>
		<updated>2026-05-06T14:59:12Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.0</generator>

	<entry>
		<id>https://wiki.twig.es/index.php?title=Tcl_:_read_a_file&amp;diff=264&amp;oldid=prev</id>
		<title>George2: Created page with &quot;http://wiki.tcl.tk/367&lt;br&gt; One way to get file data in Tcl is to 'slurp' up the file into a text variable. This works really well if the files are known to be small.       #  ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.twig.es/index.php?title=Tcl_:_read_a_file&amp;diff=264&amp;oldid=prev"/>
				<updated>2014-05-23T16:07:01Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;http://wiki.tcl.tk/367&amp;lt;br&amp;gt; One way to get file data in Tcl is to &amp;#039;slurp&amp;#039; up the file into a text variable. This works really well if the files are known to be small.       #  ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;http://wiki.tcl.tk/367&amp;lt;br&amp;gt;&lt;br /&gt;
One way to get file data in Tcl is to 'slurp' up the file into a text variable. This works really well if the files are known to be small.&lt;br /&gt;
&lt;br /&gt;
     #  Slurp up the data file&lt;br /&gt;
     set fp [open &amp;quot;somefile&amp;quot; r]&lt;br /&gt;
     set file_data [read $fp]&lt;br /&gt;
     close $fp&lt;br /&gt;
&lt;br /&gt;
Now you can split file_data into lines, and process it to your heart's content. NOTE: The mention of split is important here- input data is seldom well-behaved/structured, and needs to be processed in this way to ensure that any potential Tcl metacharacters are appropriately quoted into list format.&lt;br /&gt;
&lt;br /&gt;
     #  Process data file&lt;br /&gt;
     set data [split $file_data &amp;quot;\n&amp;quot;]&lt;br /&gt;
     foreach line $data {&lt;br /&gt;
          # do some line processing here&lt;br /&gt;
     }&lt;/div&gt;</summary>
		<author><name>George2</name></author>	</entry>

	</feed>