Commits

Shlomi Fish committed ba7b212

Start working on the examples.

  • Participants
  • Parent commits 62a5825

Comments (0)

Files changed (1)

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

 #include '../template.wml'
 #include "files_dirs_modules.wml"
 
+<page_extra_head_elements>
+<script type="text/javascript" src="$(ROOT)/js/jquery-ui-1.9.2.custom.min.js"></script>
+<link rel="stylesheet" type="text/css" href="$(ROOT)/css/smoothness/jquery-ui-1.9.2.custom.min.css" media="screen, projection" />
+</page_extra_head_elements>
+
 <latemp_subject "Files and Directories Handling in Perl" />
 
 <p>
 
 <files_and_directories_modules />
 
+<h2 id="examples">Examples</h2>
+
+<p>
+These are a set of examples for manipulating files and directories using Perl.
+Each will be shown in several versions including ones using IO-All, ones using
+core modules, and if relevant ones from the command line.
+</p>
+
+<define-tag perl_code endtag="required">
+<pre class="perl">
+\#!/usr/bin/perl
+
+use strict;
+use warnings;
+%body
+</pre>
+</define-tag>
+
+<script type="text/javascript">
+    $(function() {
+        $(".tabs").tabs();
+    });
+</script>
+
+<h3 id="copying_a_file">Copying a file</h3>
+
+<div class="tabs">
+
+<ul>
+
+<li><a href="#copying_a_file_io_all">IO-All</a></li>
+
+<li><a href="#copying_a_file_core">Core Perl</a></li>
+
+</ul>
+
+<div id="copying_a_file_io_all">
+
+<perl_code>
+use IO::All;
+
+my ($source_filename, $dest_filename) = @_;
+io-&gt;file($source_filename) &gt; io-&gt;file($dest_filename);
+</perl_code>
+
+</div>
+
+<div id="copying_a_file_core">
+
+<perl_code>
+
+use File::Copy qw(copy);
+
+my ($source_filename, $dest_filename) = @_;
+
+copy($source_filename, $dest_filename);
+</perl_code>
+
+</div>
+
+</div>