Commits

Shlomi Fish committed 4c75112

Add an example.

  • Participants
  • Parent commits ed112b4

Comments (0)

Files changed (1)

src/topics/files-and-directories/index.html.wml

 
 </div>
 
+<h3 id="overwrite_a_file">Overwriting a file with text.</h3>
+
+<div class="tabs">
+
+<ul>
+
+<li><a href="#overwrite_a_file_io_all">IO-All</a></li>
+
+<li><a href="#overwrite_a_file_core">Core Perl</a></li>
+
+</ul>
+
+<div id="overwrite_a_file_io_all">
+
+<perl_code>
+use IO::All;
+
+io->file("output.txt")->utf8->print("Hello World!\n");
+</perl_code>
+
+</div>
+
+<div id="overwrite_a_file_core">
+
+<perl_code>
+use autodie;
+
+open my $out, '>:encoding(utf8)', "output.txt";
+print {$out} "Hello World!\n";
+close($out);
+</perl_code>
+
+</div>
+
+</div>
+
 <h3 id="processing_lines_of_a_file">Processing the Lines of a File</h3>
 
 <div class="tabs">