Commits

Shlomi Fish committed 56be6c8

Synced Perl-for-Newbies from the Homepage.

(Adding Part 5.)

The revision of the homepage when this was done is:

5053 - ee0c4c6528dc35c70cef265779383f9e77ccb550 .

  • Participants
  • Parent commits ebe63ad

Comments (0)

Files changed (37)

File lib/MyNavData.pm

                             url => "tutorials/perl-for-newbies/part4/",
                             title => "Useful Perl Paradigms",
                         },
+                        {
+                            text => "Part 5",
+                            url => "tutorials/perl-for-newbies/part5/",
+                            title => "Good Programming Practices",
+                        },
                     ],
                 },
                 {

File lib/tutorials/perl-for-newbies/lect1-all-in-one/arrays/comma1.pl

 @lines = ("One fish", "Two fish", "Red fish", "Blue fish");
 
-for $a (0 .. $#lines)
+for $idx (0 .. $#lines)
 {
-    print $lines[$a], "\n";
+    print $lines[$idx], "\n";
 }

File lib/tutorials/perl-for-newbies/lect1-all-in-one/arrays/comma2.pl

 @primes = (@primes1,@primes2,17);
 @primes = (@primes,19);
 
-for $a (0 .. $#primes)
+for $idx (0 .. $#primes)
 {
-	print $primes[$a], "\n";
+	print $primes[$idx], "\n";
 }

File lib/tutorials/perl-for-newbies/lect1-all-in-one/conditionals/even_numbers.pl

-for $a (1 .. 100)
+for $n (1 .. 100)
 {
-    if (($a % 3) != 0)
+    if (($n % 3) != 0)
     {
-        print $a,"\n";
+        print $n,"\n";
     }
 }

File lib/tutorials/perl-for-newbies/lect1-all-in-one/conditionals/non_div3_numbers.pl

-for $a (1 .. 100)
+for $n (1 .. 100)
 {
-    if (($a % 3) != 0)
+    if (($n % 3) != 0)
     {
-        print $a,"\n";
+        print $n, "\n";
     }
 }

File lib/tutorials/perl-for-newbies/lect1-all-in-one/index.html

 <p>An example will illustrate it:</p>
 <div class="code_block"><pre>
 <span class="Identifier">$myvar</span> = <span class="Constant">17</span>;
-<span class="Identifier">$a</span> = <span class="Constant">2</span>;
-<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$a</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> = <span class="Constant">10</span>;
-<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$a</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> = <span class="Constant">75</span>;
-<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$a</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> = <span class="Constant">24</span>;
-<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$a</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> = <span class="Constant">2</span>;
+<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$x</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> = <span class="Constant">10</span>;
+<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$x</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> = <span class="Constant">75</span>;
+<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$x</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> = <span class="Constant">24</span>;
+<span class="Statement">print</span> <span class="Identifier">$myvar</span>, <span class="Constant">&quot; * &quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot; = &quot;</span> , (<span class="Identifier">$myvar</span>*<span class="Identifier">$x</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 </pre></div>
 <p>
 The output of this program is:
 </p>
 <ol>
 <li>
-The value of <tt>$a</tt> changes throughout the program. It's perfectly fine,
+The value of <tt>$x</tt> changes throughout the program. It's perfectly fine,
 and usually even necessary to modify the value of a variable.
 </li>
 <li>
 "$myvar = $myvar / $value" and similar operations. Here's an example:
 </p>
 <div class="code_block"><pre>
-<span class="Identifier">$a</span> = <span class="Constant">1</span>;
-<span class="Identifier">$b</span> = <span class="Constant">0</span>;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span> += <span class="Constant">1</span>;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span> += <span class="Constant">1</span>;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span> += <span class="Constant">1</span>;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span> += <span class="Constant">1</span>;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span> += <span class="Constant">1</span>;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> = <span class="Constant">1</span>;
+<span class="Identifier">$y</span> = <span class="Constant">0</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span> += <span class="Constant">1</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span> += <span class="Constant">1</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span> += <span class="Constant">1</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span> += <span class="Constant">1</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span> += <span class="Constant">1</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 </pre></div>
 <p>
-Since the operations <tt>$a += 1</tt> and <tt>$a -= 1</tt> are so commonly used,
-they were also assigned a separate operator. One can use <tt>$a++</tt> and
-<tt>$a--</tt> to perform them. For example, the above program could have
+Since the operations <tt>$x += 1</tt> and <tt>$x -= 1</tt> are so commonly used,
+they were also assigned a separate operator. One can use <tt>$x++</tt> and
+<tt>$x--</tt> to perform them. For example, the above program could have
 been written as:
 </p>
 <div class="code_block"><pre>
-<span class="Identifier">$a</span> = <span class="Constant">1</span>;
-<span class="Identifier">$b</span> = <span class="Constant">0</span>;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span>++;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span>++;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span>++;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span>++;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-<span class="Identifier">$a</span> *= <span class="Constant">2</span>; <span class="Identifier">$b</span>++;
-<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> = <span class="Constant">1</span>;
+<span class="Identifier">$y</span> = <span class="Constant">0</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span>++;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span>++;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span>++;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span>++;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Identifier">$x</span> *= <span class="Constant">2</span>; <span class="Identifier">$y</span>++;
+<span class="Statement">print</span> <span class="Constant">&quot;2^&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;=&quot;</span>, <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 </pre></div>
 <hr />
 
 <table border="1" summary="">
 <tr>
 <td>
-<tt>$a == $b</tt>
+<tt>$x == $y</tt>
 </td>
 <td>
-<tt>$a</tt> and <tt>$b</tt> are equal.
+<tt>$x</tt> and <tt>$y</tt> are equal.
 </td>
 </tr>
 <tr>
 <td>
-<tt>$a &gt; $b</tt>
+<tt>$x &gt; $y</tt>
 </td>
 <td>
-<tt>$a</tt> is greater than <tt>$b</tt>
+<tt>$x</tt> is greater than <tt>$y</tt>
 </td>
 </tr>
 <tr>
 <td>
-<tt>$a &lt; $b</tt>
+<tt>$x &lt; $y</tt>
 </td>
 <td>
-<tt>$a</tt> is lesser than <tt>$b</tt>
+<tt>$x</tt> is lesser than <tt>$y</tt>
 </td>
 </tr>
 <tr>
 <td>
-<tt>$a &gt;= $b</tt>
+<tt>$x &gt;= $y</tt>
 </td>
 <td>
-<tt>$a</tt> is greater or equal to <tt>$b</tt>
+<tt>$x</tt> is greater or equal to <tt>$y</tt>
 </td>
 </tr>
 <tr>
 <td>
-<tt>$a &lt;= $b</tt>
+<tt>$x &lt;= $y</tt>
 </td>
 <td>
-<tt>$a</tt> is lesser or equal to <tt>$b</tt>
+<tt>$x</tt> is lesser or equal to <tt>$y</tt>
 </td>
 </tr>
 <tr>
 <td>
-<tt>$a != $b</tt>
+<tt>$x != $y</tt>
 </td>
 <td>
-<tt>$a</tt> is not equal to <tt>$b</tt>
+<tt>$x</tt> is not equal to <tt>$y</tt>
 </td>
 </tr>
 </table>
 between 1 and 100 that are not divisible by 3:
 </p>
 <div class="code_block"><pre>
-<span class="Statement">for</span> <span class="Identifier">$a</span> (<span class="Constant">1</span> .. <span class="Constant">100</span>)
+<span class="Statement">for</span> <span class="Identifier">$n</span> (<span class="Constant">1</span> .. <span class="Constant">100</span>)
 {
-    <span class="Statement">if</span> ((<span class="Identifier">$a</span> % <span class="Constant">3</span>) != <span class="Constant">0</span>)
+    <span class="Statement">if</span> ((<span class="Identifier">$n</span> % <span class="Constant">3</span>) != <span class="Constant">0</span>)
     {
-        <span class="Statement">print</span> <span class="Identifier">$a</span>,<span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+        <span class="Statement">print</span> <span class="Identifier">$n</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
     }
 }
 </pre></div>
 <td>
 <h2>&amp;&amp;</h2>
 <p>
-<tt>$a &amp;&amp; $b</tt> evaluates to true if both <tt>$a</tt> and <tt>$b</tt> are true.
-It is called the logical and of the two operands <tt>$a</tt> and <tt>$b</tt>.
+<tt>$x &amp;&amp; $y</tt> evaluates to true if both <tt>$x</tt> and <tt>$y</tt> are true.
+It is called the “logical and” of the two operands <tt>$x</tt> and <tt>$y</tt>.
 </p>
 </td>
 </tr>
 <td>
 <h2>||</h2>
 <p>
-<tt>$a || $b</tt> (called the logical or of <tt>$a</tt> and <tt>$b</tt>) is
+<tt>$x || $y</tt> (called the logical or of <tt>$x</tt> and <tt>$y</tt>) is
 evaluated to true if one or both of its operands are true.
 </p>
 </td>
 <td>
 <h2>!</h2>
 <p>
-<tt>! $a</tt> (pronounced "not <tt>$a</tt>") evaluates to true
-if <tt>$a</tt> is false.
+<tt>! $x</tt> (pronounced “not <tt>$x</tt>”) evaluates to true
+if <tt>$x</tt> is false.
 </p>
 </td>
 </tr>
 "ROW_LOOP" is the label for the outer loop, and it can be seen that
 <tt>next</tt> uses it as a parameter. All in all, <tt>next</tt> and
 <tt>last</tt> are sometimes very convenient (but don't tell it to
-<a href="http://en.wikipedia.org/wiki/Edsger_Dijkstra">Edsgar W.
+<a href="http://en.wikipedia.org/wiki/Edsger_Dijkstra">Edsger W.
 Dijkstra</a>'s face!), so you will see them being used often.
 </p>
 <hr />
 <div class="code_block"><pre>
 <span class="Identifier">@lines</span> = (<span class="Constant">&quot;One fish&quot;</span>, <span class="Constant">&quot;Two fish&quot;</span>, <span class="Constant">&quot;Red fish&quot;</span>, <span class="Constant">&quot;Blue fish&quot;</span>);
 
-<span class="Statement">for</span> <span class="Identifier">$a</span> (<span class="Constant">0</span> .. <span class="Identifier">$#lines</span>)
+<span class="Statement">for</span> <span class="Identifier">$idx</span> (<span class="Constant">0</span> .. <span class="Identifier">$#lines</span>)
 {
-    <span class="Statement">print</span> <span class="Identifier">$lines[$a]</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+    <span class="Statement">print</span> <span class="Identifier">$lines[$idx]</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 }
 </pre></div>
 <p>
 <span class="Identifier">@primes</span> = (<span class="Identifier">@primes1</span>,<span class="Identifier">@primes2</span>,<span class="Constant">17</span>);
 <span class="Identifier">@primes</span> = (<span class="Identifier">@primes</span>,<span class="Constant">19</span>);
 
-<span class="Statement">for</span> <span class="Identifier">$a</span> (<span class="Constant">0</span> .. <span class="Identifier">$#primes</span>)
+<span class="Statement">for</span> <span class="Identifier">$idx</span> (<span class="Constant">0</span> .. <span class="Identifier">$#primes</span>)
 {
-	<span class="Statement">print</span> <span class="Identifier">$primes[$a]</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+	<span class="Statement">print</span> <span class="Identifier">$primes[$idx]</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 }
 </pre></div>
 <p>
 you can use either one interchangeably.
 </p>
 <p>
-<tt>$a .. $b</tt> is a special operator that returns an array containing the
-sequence of consecutive integers from <tt>$a</tt> up to and including
-<tt>$b</tt>. Now one can fully understand the <tt>for $i (1 .. 10)</tt>
+<tt>$x .. $y</tt> is a special operator that returns an array containing the
+sequence of consecutive integers from <tt>$x</tt> up to and including
+<tt>$y</tt>. Now one can fully understand the <tt>for $i (1 .. 10)</tt>
 construct that we used in the beginning of this lecture.
 </p>
 <hr />

File lib/tutorials/perl-for-newbies/lect1-all-in-one/variables/plus-equal1.pl

-$a = 1;
-$b = 0;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b += 1;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b += 1;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b += 1;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b += 1;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b += 1;
-print "2^", $b, "=", $a, "\n";
+$x = 1;
+$y = 0;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y += 1;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y += 1;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y += 1;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y += 1;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y += 1;
+print "2^", $y, "=", $x, "\n";
 

File lib/tutorials/perl-for-newbies/lect1-all-in-one/variables/plus-equal2.pl

-$a = 1;
-$b = 0;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b++;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b++;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b++;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b++;
-print "2^", $b, "=", $a, "\n";
-$a *= 2; $b++;
-print "2^", $b, "=", $a, "\n";
+$x = 1;
+$y = 0;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y++;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y++;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y++;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y++;
+print "2^", $y, "=", $x, "\n";
+$x *= 2; $y++;
+print "2^", $y, "=", $x, "\n";
 

File lib/tutorials/perl-for-newbies/lect1-all-in-one/variables/var1.pl

 $myvar = 17;
-$a = 2;
-print $myvar, " * ", $a, " = " , ($myvar*$a), "\n";
-$a = 10;
-print $myvar, " * ", $a, " = " , ($myvar*$a), "\n";
-$a = 75;
-print $myvar, " * ", $a, " = " , ($myvar*$a), "\n";
-$a = 24;
-print $myvar, " * ", $a, " = " , ($myvar*$a), "\n";
+$x = 2;
+print $myvar, " * ", $x, " = " , ($myvar*$x), "\n";
+$x = 10;
+print $myvar, " * ", $x, " = " , ($myvar*$x), "\n";
+$x = 75;
+print $myvar, " * ", $x, " = " , ($myvar*$x), "\n";
+$x = 24;
+print $myvar, " * ", $x, " = " , ($myvar*$x), "\n";

File lib/tutorials/perl-for-newbies/lect2-all-in-one/files/print.pl

 my $pyramid_side = 20;
 
 open my $out, ">", "pyramid.txt";
-for($a=1 ; $a <= $pyramid_side ; $a++)
+for ($l=1 ; $l <= $pyramid_side ; $l++)
 {
-    print {$out} "X" x $a;
+    print {$out} "X" x $l;
     print {$out} "\n";
 }
 close($out);

File lib/tutorials/perl-for-newbies/lect2-all-in-one/files/print2.pl

 open my $seq1, ">", "seq1.txt";
 open my $seq2, ">", "seq2.txt";
 
-for($a=0;$a<100;$a++)
+for (my $x=0 ; $x < 100 ; $x++)
 {
-    print {$seq1} $a, "\n";
-    print {$seq2} $a, "\n";
-    print {$seq1} ($a+0.1);
-    print {$seq2} ($a+0.5);
+    print {$seq1} $x, "\n";
+    print {$seq2} $x, "\n";
+    print {$seq1} ($x+0.1);
+    print {$seq2} ($x+0.5);
     print {$seq1} "\n";
     print {$seq2} "\n";
 }

File lib/tutorials/perl-for-newbies/lect2-all-in-one/functions/splitting.pl

 sub mysplit
 {
     my ($total, $num_elems, @accum) = @_;
-    my (@ret, @new_accum);
-
 
     if ($num_elems == 1)
     {
         return;
     }
 
-    for(my $a=0;$a<=$total;$a++)
+    for (my $item=0 ; $item <= $total ; $item++)
     {
-        @new_accum = (@accum, $a);
-        mysplit($total-$a, $num_elems-1, @new_accum);
+        my @new_accum = (@accum, $item);
+        mysplit($total-$item, $num_elems-1, @new_accum);
     }
 }
 
 mysplit(10,3);
 
-

File lib/tutorials/perl-for-newbies/lect2-all-in-one/functions/splitting_shift.pl

     my $total = shift;
     my $num_elems = shift;
     my @accum = @_;
-    my (@ret, @new_accum);
-
 
     if ($num_elems == 1)
     {
         return;
     }
 
-    for(my $a=0;$a<=$total;$a++)
+    for (my $item = 0 ; $item <= $total ; $item++)
     {
-        @new_accum = (@accum, $a);
-        mysplit($total-$a, $num_elems-1, @new_accum);
+        my @new_accum = (@accum, $item);
+        mysplit($total-$item, $num_elems-1, @new_accum);
     }
 }
 

File lib/tutorials/perl-for-newbies/lect2-all-in-one/index.html

 </p>
 <p>
 A subtantial difference between the notation
-<tt>for($a=0 ; $a&lt;$b ; $a++)</tt> and between
-<tt>for $a (0 .. ($b-1))</tt> is that the first accommodates
-itself to changes in <tt>$b</tt>, while the second will iterate for a
+<tt>for($i=0 ; $i&lt;$limit ; $i++)</tt> and between
+<tt>for $i (0 .. ($limit-1))</tt> is that the first accommodates
+itself to changes in <tt>$limit</tt>, while the second will iterate for a
 constant number of times. Of course, you can make the first one
-similar to the second by assigning the value of <tt>$b</tt> to a third
+similar to the second by assigning the value of <tt>$limit</tt> to a third
 variable that will remain constant. Still, the second notation is
 usually safer from that sense.
 </p>
 Here's an example:
 </p>
 <div class="code_block"><pre>
-<span class="Identifier">$a</span> = <span class="Constant">5</span>;
-<span class="Identifier">$b</span> = <span class="Constant">1000</span>;
+<span class="Identifier">$x</span> = <span class="Constant">5</span>;
+<span class="Identifier">$y</span> = <span class="Constant">1000</span>;
 {
-    <span class="Statement">my</span> (<span class="Identifier">$b</span>);
-    <span class="Statement">for</span>(<span class="Identifier">$b</span>=<span class="Constant">0</span>;<span class="Identifier">$b</span>&lt;<span class="Constant">10</span>;<span class="Identifier">$b</span>++)
+    <span class="Statement">my</span> (<span class="Identifier">$y</span>);
+    <span class="Statement">for</span>(<span class="Identifier">$y</span>=<span class="Constant">0</span>;<span class="Identifier">$y</span>&lt;<span class="Constant">10</span>;<span class="Identifier">$y</span>++)
     {
-        <span class="Statement">print</span> <span class="Identifier">$a</span>, <span class="Constant">&quot;*&quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot; = &quot;</span>, (<span class="Identifier">$a</span>*<span class="Identifier">$b</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+        <span class="Statement">print</span> <span class="Identifier">$x</span>, <span class="Constant">&quot;*&quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot; = &quot;</span>, (<span class="Identifier">$x</span>*<span class="Identifier">$y</span>), <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
     }
 }
 
-<span class="Statement">print</span> <span class="Constant">&quot;Now, </span><span class="Special">\$</span><span class="Constant">b is &quot;</span>, <span class="Identifier">$b</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;Now, </span><span class="Special">\$</span><span class="Constant">y is &quot;</span>, <span class="Identifier">$y</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 </pre></div>
 <p>
 If you wish to declare more than one variable as local you should use
 <span class="Statement">sub </span><span class="Identifier">mysplit</span>
 {
     <span class="Statement">my</span> (<span class="Identifier">$total</span>, <span class="Identifier">$num_elems</span>, <span class="Identifier">@accum</span>) = <span class="Identifier">@_</span>;
-    <span class="Statement">my</span> (<span class="Identifier">@ret</span>, <span class="Identifier">@new_accum</span>);
-
 
     <span class="Statement">if</span> (<span class="Identifier">$num_elems</span> == <span class="Constant">1</span>)
     {
         <span class="Statement">return</span>;
     }
 
-    <span class="Statement">for</span>(<span class="Statement">my</span> <span class="Identifier">$a</span>=<span class="Constant">0</span>;<span class="Identifier">$a</span>&lt;=<span class="Identifier">$total</span>;<span class="Identifier">$a</span>++)
+    <span class="Statement">for</span> (<span class="Statement">my</span> <span class="Identifier">$item</span>=<span class="Constant">0</span> ; <span class="Identifier">$item</span> &lt;= <span class="Identifier">$total</span> ; <span class="Identifier">$item</span>++)
     {
-        <span class="Identifier">@new_accum</span> = (<span class="Identifier">@accum</span>, <span class="Identifier">$a</span>);
-        mysplit(<span class="Identifier">$total</span>-<span class="Identifier">$a</span>, <span class="Identifier">$num_elems</span>-<span class="Constant">1</span>, <span class="Identifier">@new_accum</span>);
+        <span class="Statement">my</span> <span class="Identifier">@new_accum</span> = (<span class="Identifier">@accum</span>, <span class="Identifier">$item</span>);
+        mysplit(<span class="Identifier">$total</span>-<span class="Identifier">$item</span>, <span class="Identifier">$num_elems</span>-<span class="Constant">1</span>, <span class="Identifier">@new_accum</span>);
     }
 }
 
     <span class="Statement">my</span> <span class="Identifier">$total</span> = <span class="Statement">shift</span>;
     <span class="Statement">my</span> <span class="Identifier">$num_elems</span> = <span class="Statement">shift</span>;
     <span class="Statement">my</span> <span class="Identifier">@accum</span> = <span class="Identifier">@_</span>;
-    <span class="Statement">my</span> (<span class="Identifier">@ret</span>, <span class="Identifier">@new_accum</span>);
-
 
     <span class="Statement">if</span> (<span class="Identifier">$num_elems</span> == <span class="Constant">1</span>)
     {
         <span class="Statement">return</span>;
     }
 
-    <span class="Statement">for</span>(<span class="Statement">my</span> <span class="Identifier">$a</span>=<span class="Constant">0</span>;<span class="Identifier">$a</span>&lt;=<span class="Identifier">$total</span>;<span class="Identifier">$a</span>++)
+    <span class="Statement">for</span> (<span class="Statement">my</span> <span class="Identifier">$item</span> = <span class="Constant">0</span> ; <span class="Identifier">$item</span> &lt;= <span class="Identifier">$total</span> ; <span class="Identifier">$item</span>++)
     {
-        <span class="Identifier">@new_accum</span> = (<span class="Identifier">@accum</span>, <span class="Identifier">$a</span>);
-        mysplit(<span class="Identifier">$total</span>-<span class="Identifier">$a</span>, <span class="Identifier">$num_elems</span>-<span class="Constant">1</span>, <span class="Identifier">@new_accum</span>);
+        <span class="Statement">my</span> <span class="Identifier">@new_accum</span> = (<span class="Identifier">@accum</span>, <span class="Identifier">$item</span>);
+        mysplit(<span class="Identifier">$total</span>-<span class="Identifier">$item</span>, <span class="Identifier">$num_elems</span>-<span class="Constant">1</span>, <span class="Identifier">@new_accum</span>);
     }
 }
 
 <span class="Statement">my</span> <span class="Identifier">$pyramid_side</span> = <span class="Constant">20</span>;
 
 <span class="Statement">open</span> <span class="Statement">my</span> <span class="Identifier">$out</span>, <span class="Constant">&quot;&gt;&quot;</span>, <span class="Constant">&quot;pyramid.txt&quot;</span>;
-<span class="Statement">for</span>(<span class="Identifier">$a</span>=<span class="Constant">1</span> ; <span class="Identifier">$a</span> &lt;= <span class="Identifier">$pyramid_side</span> ; <span class="Identifier">$a</span>++)
+<span class="Statement">for</span> (<span class="Identifier">$l</span>=<span class="Constant">1</span> ; <span class="Identifier">$l</span> &lt;= <span class="Identifier">$pyramid_side</span> ; <span class="Identifier">$l</span>++)
 {
-    <span class="Statement">print {</span><span class="Identifier">$out</span><span class="Statement">}</span> <span class="Constant">&quot;X&quot;</span> x <span class="Identifier">$a</span>;
+    <span class="Statement">print {</span><span class="Identifier">$out</span><span class="Statement">}</span> <span class="Constant">&quot;X&quot;</span> x <span class="Identifier">$l</span>;
     <span class="Statement">print {</span><span class="Identifier">$out</span><span class="Statement">}</span> <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 }
 <span class="Statement">close</span>(<span class="Identifier">$out</span>);
 <span class="Statement">open</span> <span class="Statement">my</span> <span class="Identifier">$seq1</span>, <span class="Constant">&quot;&gt;&quot;</span>, <span class="Constant">&quot;seq1.txt&quot;</span>;
 <span class="Statement">open</span> <span class="Statement">my</span> <span class="Identifier">$seq2</span>, <span class="Constant">&quot;&gt;&quot;</span>, <span class="Constant">&quot;seq2.txt&quot;</span>;
 
-<span class="Statement">for</span>(<span class="Identifier">$a</span>=<span class="Constant">0</span>;<span class="Identifier">$a</span>&lt;<span class="Constant">100</span>;<span class="Identifier">$a</span>++)
+<span class="Statement">for</span> (<span class="Statement">my</span> <span class="Identifier">$x</span>=<span class="Constant">0</span> ; <span class="Identifier">$x</span> &lt; <span class="Constant">100</span> ; <span class="Identifier">$x</span>++)
 {
-    <span class="Statement">print {</span><span class="Identifier">$seq1</span><span class="Statement">}</span> <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-    <span class="Statement">print {</span><span class="Identifier">$seq2</span><span class="Statement">}</span> <span class="Identifier">$a</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-    <span class="Statement">print {</span><span class="Identifier">$seq1</span><span class="Statement">}</span> (<span class="Identifier">$a</span>+<span class="Constant">0.1</span>);
-    <span class="Statement">print {</span><span class="Identifier">$seq2</span><span class="Statement">}</span> (<span class="Identifier">$a</span>+<span class="Constant">0.5</span>);
+    <span class="Statement">print {</span><span class="Identifier">$seq1</span><span class="Statement">}</span> <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+    <span class="Statement">print {</span><span class="Identifier">$seq2</span><span class="Statement">}</span> <span class="Identifier">$x</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+    <span class="Statement">print {</span><span class="Identifier">$seq1</span><span class="Statement">}</span> (<span class="Identifier">$x</span>+<span class="Constant">0.1</span>);
+    <span class="Statement">print {</span><span class="Identifier">$seq2</span><span class="Statement">}</span> (<span class="Identifier">$x</span>+<span class="Constant">0.5</span>);
     <span class="Statement">print {</span><span class="Identifier">$seq1</span><span class="Statement">}</span> <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
     <span class="Statement">print {</span><span class="Identifier">$seq2</span><span class="Statement">}</span> <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 }
 7.8. Useful Flags
 </h1>
 <p>
-There are other flags besides <tt>e</tt> that can be appended to the end
+There are other flags than <tt>e</tt> that can be appended to the end
 of the match or substitution.
 </p>
 <p>
 Note that once perl encounters a <tt>$</tt>-sign, it will try to use as
 many characters as possible from the string as the variable name,
 even if a variable by that name does not exist. Therefore, if you write
-<tt>$ab</tt> inside a string, it will not take the value of <tt>$a</tt> and
-append the string "b" to it! To overcome this limitation, you can limit the
+<tt>$xy</tt> inside a string, it will not take the value of <tt>$x</tt> and
+append the string "y" to it! To overcome this limitation, you can limit the
 variable name using curly braces:
 <tt>"Hello ${boy}and${girl}"</tt>.
 </p>
 <p>
 In any case, interpolation is especially useful for building regular
-expression, since the string may contain control characters.
+expressions, since the string may contain control characters.
 </p>
 <hr />
 
 <p>
 Within the comparison block, the variables <tt>$a</tt> and <tt>$b</tt> indicate
 the two elements to be compared. If the expression returns a negative value
-it means that <tt>$a</tt> should precede <tt>$b</tt>. If it's positive, it means
-that <tt>$b</tt> should come before <tt>$a</tt>. If it's zero it indicates that
-it does not matter which one will come first.
+it means that <tt>$a</tt> should precede <tt>$b</tt>. If it is positive, it
+means that <tt>$b</tt> should come before <tt>$a</tt>. If it is zero, it
+indicates that it does not matter which one will come first.
 </p>
 <p>
 The following example sorts an array of integers numerically:
 </h1>
 <p>
 Perl has two operators <tt>&lt;=&gt;</tt> and <tt>cmp</tt>, which are very
-useful when wishing to sort arrays. <tt>$a &lt;=&gt; $b</tt> returns -1 if
-<tt>$a</tt> is numerically lesser than <tt>$b</tt>, 1 if it's greater, and
+useful when wishing to sort arrays. <tt>$x &lt;=&gt; $y</tt> returns -1 if
+<tt>$x</tt> is numerically lesser than <tt>$y</tt>, 1 if it's greater, and
 zero if they are equal.
 </p>
 <p>
 <span class="Statement">my</span> <span class="Identifier">$num_disks</span> = <span class="Statement">shift</span> || <span class="Constant">9</span>;
 
 <span class="Statement">my</span> <span class="Identifier">@towers</span> = (
-    [ <span class="Statement">reverse</span>(<span class="Constant">1</span> .. <span class="Identifier">$num_disks</span>) ],  <span class="Comment"># A [ ... ] is a dynamic reference to </span>
+    [ <span class="Statement">reverse</span>(<span class="Constant">1</span> .. <span class="Identifier">$num_disks</span>) ],  <span class="Comment"># A [ ... ] is a dynamic reference to</span>
     [ ],                           <span class="Comment"># an array</span>
     [ ]
     );
 
 <span class="Statement">sub </span><span class="Identifier">print_towers</span>
 {
-    <span class="Statement">for</span>(<span class="Statement">my</span> <span class="Identifier">$a</span>=<span class="Constant">0</span>;<span class="Identifier">$a</span>&lt;<span class="Constant">3</span>;<span class="Identifier">$a</span>++)
+    <span class="Statement">for</span>(<span class="Statement">my</span> <span class="Identifier">$i</span>=<span class="Constant">0</span> ; <span class="Identifier">$i</span> &lt; <span class="Constant">3</span> ; <span class="Identifier">$i</span>++)
     {
         <span class="Statement">print</span> <span class="Constant">&quot;: &quot;</span>;
-        <span class="Statement">print</span> <span class="Statement">join</span>(<span class="Constant">&quot; &quot;</span>, <span class="Identifier">@{$towers[$a]}</span>); <span class="Comment"># We de-reference the tower</span>
+        <span class="Statement">print</span> <span class="Statement">join</span>(<span class="Constant">&quot; &quot;</span>, <span class="Identifier">@{$towers[$i]}</span>); <span class="Comment"># We de-reference the tower</span>
         <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
     }
     <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Special">\n\n</span><span class="Constant">&quot;</span>;
     {
         <span class="Statement">return</span>;
     }
-    <span class="Comment"># Find the third column </span>
+    <span class="Comment"># Find the third column</span>
     <span class="Statement">my</span> <span class="Identifier">$intermediate</span> = <span class="Constant">0</span>+<span class="Constant">1</span>+<span class="Constant">2</span>-<span class="Identifier">$source</span>-<span class="Identifier">$dest</span>;
     move_column(<span class="Identifier">$source</span>, <span class="Identifier">$intermediate</span>, <span class="Identifier">$how_many</span>-<span class="Constant">1</span>);
     <span class="Comment"># Print the current state</span>
     <span class="Statement">my</span> <span class="Identifier">$ref_to_sum</span> = <span class="Statement">shift</span>;
     <span class="Statement">foreach</span> <span class="Statement">my</span> <span class="Identifier">$item</span> (<span class="Identifier">@_</span>)
     {
-        <span class="Comment"># The ${ ... } dereferences the variable </span>
+        <span class="Comment"># The ${ ... } dereferences the variable</span>
         <span class="Identifier">${$ref_to_sum}</span> += <span class="Identifier">$item</span>;
     }
 }
 };
 
 <span class="Statement">my</span> <span class="Identifier">$array_ref</span> = [<span class="Constant">5</span>, <span class="Constant">6</span>, <span class="Constant">7</span>, <span class="Constant">10</span>, <span class="Constant">24</span>, <span class="Constant">90</span>, <span class="Constant">14</span>];
-<span class="Statement">my</span> <span class="Identifier">$a</span> = <span class="Constant">&quot;Hello World!&quot;</span>;
-<span class="Statement">my</span> <span class="Identifier">$b</span> = \<span class="Identifier">$a</span>;
+<span class="Statement">my</span> <span class="Identifier">$x</span> = <span class="Constant">&quot;Hello World!&quot;</span>;
+<span class="Statement">my</span> <span class="Identifier">$y</span> = \<span class="Identifier">$x</span>;
 
 <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Special">\$</span><span class="Constant">array_ref:</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 
 }
 
 
-<span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Special">\n\n\$\$</span><span class="Constant">b:</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Special">\n\n\$\$</span><span class="Constant">y:</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 
-<span class="Statement">print</span> <span class="Identifier">${$b}</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+<span class="Statement">print</span> <span class="Identifier">${$y}</span>, <span class="Constant">&quot;</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 </pre></div>
 <p>
 If the expression that yields the reference is a simple one than the curly
 </h1>
 <p>
 One can execute perl commands inside the debugger. For example, typing
-<tt>print $a</tt> at the debugger prompt will print the value of the
-<tt>$a</tt> variable. You can also modify the values of variables in this
+<tt>print $x</tt> at the debugger prompt will print the value of the
+<tt>$x</tt> variable. You can also modify the values of variables in this
 way, or run functions, etc.
 </p>
 <p>
 By now, you can probably understand the perl core documents, so it is
 recommended
 that you read them in case you are looking for more information. You can
-also refer to <a href="http://perl-begin.berlios.de/">the Perl Beginners'
+also refer to <a href="http://perl-begin.org/">the Perl Beginners'
 Site</a> for more sources of information as well as ways to get help online.
 </p>
 <p>

File lib/tutorials/perl-for-newbies/lect2-all-in-one/my/my1.pl

 
-$a = 5;
-$b = 1000;
+$x = 5;
+$y = 1000;
 {
-    my ($b);
-    for($b=0;$b<10;$b++)
+    my ($y);
+    for($y=0;$y<10;$y++)
     {
-        print $a, "*", $b, " = ", ($a*$b), "\n";
+        print $x, "*", $y, " = ", ($x*$y), "\n";
     }
 }
 
-print "Now, \$b is ", $b, "\n";
+print "Now, \$y is ", $y, "\n";
 

File lib/tutorials/perl-for-newbies/lect2-all-in-one/references/deref1.pl

 };
 
 my $array_ref = [5, 6, 7, 10, 24, 90, 14];
-my $a = "Hello World!";
-my $b = \$a;
+my $x = "Hello World!";
+my $y = \$x;
 
 print "\$array_ref:\n";
 
 }
 
 
-print "\n\n\$\$b:\n";
+print "\n\n\$\$y:\n";
 
-print ${$b}, "\n";
+print ${$y}, "\n";
 
-
-
-

File lib/tutorials/perl-for-newbies/lect2-all-in-one/references/hanoi.pl

 
 sub print_towers
 {
-    for(my $a=0;$a<3;$a++)
+    for(my $i=0 ; $i < 3 ; $i++)
     {
         print ": ";
-        print join(" ", @{$towers[$a]}); # We de-reference the tower
+        print join(" ", @{$towers[$i]}); # We de-reference the tower
         print "\n";
     }
     print "\n\n";

File lib/tutorials/perl-for-newbies/lect3-all-in-one/index.html

 <span class="Statement">use strict</span>;
 <span class="Statement">use warnings</span>;
 
-<span class="Comment"># This is a value that can be inputted or outputted by the </span>
+<span class="Comment"># This is a value that can be inputted or outputted by the</span>
 <span class="Comment"># mini-interpreter.</span>
 <span class="Statement">my</span> <span class="Identifier">$a_value</span>;
 
 <a href="http://www-mitpress.mit.edu/sicp/">"Structure and Interpretation of Computer Programs"</a> in which a similar code can be found written in Scheme.
 </p>
 <div class="code_block"><pre>
-<span class="PreProc">#!/usr/bin/perl</span>
 
-<span class="Statement">use strict</span>;
-<span class="Statement">use warnings</span>;
-
-<span class="Statement">sub </span><span class="Identifier">create_bank_account</span>
-{
-    <span class="Statement">my</span> <span class="Identifier">$name</span> = <span class="Statement">shift</span>;
-    <span class="Statement">my</span> <span class="Identifier">$total</span> = <span class="Constant">0</span>;
-
-    <span class="Statement">my</span> <span class="Identifier">$deposit</span> = <span class="Statement">sub </span>{
-        <span class="Statement">my</span> <span class="Identifier">$how_much</span> = <span class="Statement">shift</span>;
-
-        <span class="Identifier">$total</span> += <span class="Identifier">$how_much</span>;
-    };
-
-    <span class="Statement">my</span> <span class="Identifier">$print</span> = <span class="Statement">sub </span>{
-        <span class="Statement">my</span> <span class="Identifier">$title</span> = <span class="Statement">shift</span>;
-
-        <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Identifier">$name</span><span class="Constant"> has </span><span class="Identifier">$total</span><span class="Constant"> NIS.</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-    };
-
-    <span class="Statement">my</span> <span class="Identifier">$can_extract</span> = <span class="Statement">sub </span>{
-        <span class="Statement">my</span> <span class="Identifier">$how_much</span> = <span class="Statement">shift</span>;
-
-        <span class="Statement">if</span> (<span class="Identifier">$how_much</span> &lt;= <span class="Constant">0</span>)
-        {
-            <span class="Statement">return</span>;
-        }
-
-        <span class="Statement">if</span> (<span class="Identifier">$total</span> &gt;= <span class="Identifier">$how_much</span>)
-        {
-            <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Identifier">$name</span><span class="Constant"> can afford to pay it!</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-        }
-        <span class="Statement">else</span>
-        {
-            <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Identifier">$name</span><span class="Constant"> cannot afford to pay it!</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
-        }
-    };
-
-    <span class="Statement">my</span> <span class="Identifier">%ops</span> =
-        (
-            <span class="Constant">&quot;deposit&quot;</span> =&gt; <span class="Identifier">$deposit</span>,
-            <span class="Constant">&quot;print&quot;</span> =&gt; <span class="Identifier">$print</span>,
-            <span class="Constant">&quot;can_extract&quot;</span> =&gt; <span class="Identifier">$can_extract</span>,
-        );
-
-    <span class="Statement">my</span> <span class="Identifier">$dispatch</span> = <span class="Statement">sub </span>{
-        <span class="Statement">my</span> <span class="Identifier">$op</span> = <span class="Statement">shift</span>;
-
-        <span class="Comment"># Call the matching operation with the rest of the arguments.</span>
-        <span class="Identifier">$ops{$op}</span>-&gt;(<span class="Identifier">@_</span>);
-    };
-
-    <span class="Statement">return</span> <span class="Identifier">$dispatch</span>;
-}
-
-<span class="Comment"># Create ten bank accounts</span>
-<span class="Statement">my</span> <span class="Identifier">@accounts</span> = (<span class="Statement">map {</span> create_bank_account(<span class="Constant">&quot;Person #&quot;</span>.<span class="Identifier">$_</span>) <span class="Statement">}</span> (<span class="Constant">0</span> .. <span class="Constant">9</span>));
-
-<span class="Statement">while</span> (<span class="Statement">my</span> <span class="Identifier">$line</span> = &lt;&gt;)
-{
-    <span class="Statement">chomp</span>(<span class="Identifier">$line</span>);
-    <span class="Statement">my</span> <span class="Identifier">@components</span> = <span class="Statement">split</span>(<span class="Statement">/</span><span class="Special">\s+</span><span class="Statement">/</span>, <span class="Identifier">$line</span>);
-    <span class="Statement">my</span> <span class="Identifier">$account_index</span> = <span class="Statement">shift</span>(<span class="Identifier">@components</span>);
-    <span class="Statement">my</span> <span class="Identifier">$op</span> = <span class="Statement">shift</span>(<span class="Identifier">@components</span>);
-
-    <span class="Identifier">$accounts[$account_index]</span>-&gt;(<span class="Identifier">$op</span>, <span class="Identifier">@components</span>);
-}
-
-<span class="Comment"># Usage:</span>
-<span class="Comment"># [Account Number] [Operation] [Parameters]</span>
 </pre></div>
 <hr />
 
 
 <span class="Identifier">@EXPORT</span>=(<span class="Constant">&quot;gcd&quot;</span>);
 
-<span class="Comment"># This function calculates the greatest common divisor of two integers </span>
+<span class="Comment"># This function calculates the greatest common divisor of two integers</span>
 <span class="Statement">sub </span><span class="Identifier">gcd</span>
 {
     <span class="Statement">my</span> <span class="Identifier">$m</span> = <span class="Statement">shift</span>;
     <span class="Comment"># important step.</span>
     <span class="Statement">bless</span> <span class="Identifier">$self</span>, <span class="Identifier">$class</span>;
 
-    <span class="Comment"># Now we can retrieve the other arguments passed to the </span>
+    <span class="Comment"># Now we can retrieve the other arguments passed to the</span>
     <span class="Comment"># constructor.</span>
 
     <span class="Statement">my</span> <span class="Identifier">$name</span> = <span class="Statement">shift</span> || <span class="Constant">&quot;Fooish&quot;</span>;
 <span class="Statement">use strict</span>;
 <span class="Statement">use warnings</span>;
 
-<span class="Comment"># @ISA is not lexically scoped so it has to be declared with </span>
+<span class="Comment"># @ISA is not lexically scoped so it has to be declared with</span>
 <span class="Comment"># use vars.</span>
 <span class="Comment">#</span>
 <span class="Comment"># qw(My Constant String) is equivalent to split(/\s+/, &quot;My Constant String&quot;)</span>

File lib/tutorials/perl-for-newbies/lect4-all-in-one/index.html

 <span class="Identifier">$y</span> =~ <span class="Statement">s!</span><span class="Constant">Hello</span><span class="Statement">!</span><span class="Constant">Hi</span><span class="Statement">!</span>;
 <span class="Statement">print</span> <span class="Constant">qq#</span><span class="Identifier">$y</span><span class="Special">\n</span><span class="Constant">#</span>;
 
-<span class="Statement">my</span> <span class="Identifier">@a</span> = <span class="Constant">qw{one two three}</span>;
+<span class="Statement">my</span> <span class="Identifier">@arr</span> = <span class="Constant">qw{one two three}</span>;
 <span class="Statement">for</span> <span class="Statement">my</span> <span class="Identifier">$i</span> (<span class="Constant">0</span> .. <span class="Identifier">$#a</span>)
 {
-    <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Identifier">$i</span><span class="Constant">: </span><span class="Identifier">$a[$i]</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
+    <span class="Statement">print</span> <span class="Constant">&quot;</span><span class="Identifier">$i</span><span class="Constant">: </span><span class="Identifier">$arr[$i]</span><span class="Special">\n</span><span class="Constant">&quot;</span>;
 }
 </pre></div>
 <p>
 <span class="Statement">use warnings</span>;
 
 
-<span class="Statement">my</span> <span class="Identifier">$a</span> = <span class="Constant">&quot;Hello&quot;</span>;
+<span class="Statement">my</span> <span class="Identifier">$x</span> = <span class="Constant">&quot;Hello&quot;</span>;
 <span class="Statement">my</span> <span class="Identifier">$str</span> = <span class="Constant">&quot;There you go.&quot;</span>;
 <span class="Statement">my</span> <span class="Identifier">$true</span> = <span class="Constant">&quot;False&quot;</span>;
 
 <span class="Statement">print</span> <span class="Constant">&lt;&lt;&quot;END&quot;;</span>
-<span class="Constant">The value of </span><span class="Special">\$</span><span class="Constant">a is: &quot;</span><span class="Identifier">$a</span><span class="Constant">&quot;</span>
+<span class="Constant">The value of </span><span class="Special">\$</span><span class="Constant">x is: &quot;</span><span class="Identifier">$x</span><span class="Constant">&quot;</span>
 <span class="Constant">The value of </span><span class="Special">\$</span><span class="Constant">str is: &quot;</span><span class="Identifier">$str</span><span class="Constant">&quot;</span>
 <span class="Constant">The value of true is: &quot;</span><span class="Identifier">$true</span><span class="Constant">&quot;</span>
 
 Its output is:
 </p>
 <div class="code_block"><pre>
-The value of $a is: "Hello"
+The value of $x is: "Hello"
 The value of $str is: "There you go."
 The value of true is: "False"
 

File lib/tutorials/perl-for-newbies/lect4-all-in-one/string-forms/here-doc.pl

 use warnings;
 
 
-my $a = "Hello";
+my $x = "Hello";
 my $str = "There you go.";
 my $true = "False";
 
 print <<"END";
-The value of \$a is: "$a"
+The value of \$x is: "$x"
 The value of \$str is: "$str"
 The value of true is: "$true"
 

File lib/tutorials/perl-for-newbies/lect4-all-in-one/string-forms/q_qq-examples.pl

 $y =~ s!Hello!Hi!;
 print qq#$y\n#;
 
-my @a = qw{one two three};
+my @arr = qw{one two three};
 for my $i (0 .. $#a)
 {
-    print "$i: $a[$i]\n";
+    print "$i: $arr[$i]\n";
 }

File lib/tutorials/perl-for-newbies/lect5-all-in-one/index.html

+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html
+         PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+         "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<link rel="stylesheet" href="./style.css" type="text/css" />
+
+
+
+
+<title>
+"Perl for Perl Newbies" - Part 5 - Good Programming Practices
+</title>
+</head>
+<body><div class="page">
+
+
+<table class="page-nav-bar top" summary=""><tr><td>
+<a href="#page--DIR" class="nav" accesskey="c">Contents</a></td>
+<td>
+<b>Up</b></td>
+<td>
+<b>Prev</b></td>
+<td>
+<a href="#page--intro--PAGE" class="nav" accesskey="n">Next</a></td>
+</tr></table>
+<div class="bread">
+<a href="#page--DIR">"Perl for Perl Newbies" - Part 5 - Good Programming Practices</a>
+</div>
+<h1 id="page--DIR">
+"Perl for Perl Newbies" - Part 5 - Good Programming Practices
+</h1>
+<h2 id="contents">Contents</h2>
+<ul class="contentsmain">
+<li><a href="#page--intro--PAGE" class="contents">1. Introduction</a>
+</li><li><a href="#page--testing--DIR" class="contents">2. Automated Testing</a>
+<ul class="contents">
+<li><a href="#page--testing--motivation--PAGE" class="contents">2.1. Motivation for Testing</a>
+</li><li><a href="#page--testing--demo--DIR" class="contents">2.2. Demo</a>
+<ul class="contents">
+<li><a href="#page--testing--demo--test-more--PAGE" class="contents">2.2.1. Test::More</a>
+</li><li><a href="#page--testing--demo--Build-test--PAGE" class="contents">2.2.2. ./Build test</a>
+</li></ul>
+</li><li><a href="#page--testing--types--PAGE" class="contents">2.3. Types of Tests: Unit Tests, Integration Tests, System Tests</a>
+</li><li><a href="#page--testing--mocking--PAGE" class="contents">2.4. Mocking</a>
+</li></ul>
+</li><li><a href="#page--version-control--DIR" class="contents">3. Version Control</a>
+<ul class="contents">
+<li><a href="#page--version-control--motivation--PAGE" class="contents">3.1. Motivation for Version Control</a>
+</li><li><a href="#page--version-control--mercurial-demo--PAGE" class="contents">3.2. Demo of Mercurial</a>
+</li></ul>
+</li><li><a href="#page--accessors--DIR" class="contents">4. Class Accessors</a>
+<ul class="contents">
+<li><a href="#page--accessors--example--PAGE" class="contents">4.1. Example</a>
+</li><li><a href="#page--accessors--motivation--PAGE" class="contents">4.2. Motivation</a>
+</li><li><a href="#page--accessors--cpan-modules--PAGE" class="contents">4.3. Accessor modules on the CPAN</a>
+</li></ul>
+</li><li><a href="#page--new-features--DIR" class="contents">5. Useful Features in Recent Perls</a>
+<ul class="contents">
+<li><a href="#page--new-features--use-base--PAGE" class="contents">5.1. use base</a>
+</li><li><a href="#page--new-features--lexical-filehandles--PAGE" class="contents">5.2. Lexical Filehandles</a>
+</li></ul>
+</li><li><a href="#page--local-keyword--DIR" class="contents">6. The local keyword</a>
+<ul class="contents">
+<li><a href="#page--local-keyword--use-and-abuse--PAGE" class="contents">6.1. Use and Abuse</a>
+</li></ul>
+</li><li><a href="#page--pod-documentation--DIR" class="contents">7. Using POD for Documentation</a>
+<ul class="contents">
+<li><a href="#page--pod-documentation--demo--PAGE" class="contents">7.1. POD Demonstration</a>
+</li><li><a href="#page--pod-documentation--pod-testing--PAGE" class="contents">7.2. Testing and Verifying POD</a>
+</li><li><a href="#page--pod-documentation--literate-programming--PAGE" class="contents">7.3. Literate Programming</a>
+</li><li><a href="#page--pod-documentation--extensions--PAGE" class="contents">7.4. POD Extensions</a>
+</li></ul>
+</li><li><a href="#page--module-build-and-starter--DIR" class="contents">8. Module-Build and Module-Starter</a>
+<ul class="contents">
+<li><a href="#page--module-build-and-starter--invocation--PAGE" class="contents">8.1. The Module-Starter Invocation Command</a>
+</li><li><a href="#page--module-build-and-starter--commands--PAGE" class="contents">8.2. Module-Build commands</a>
+</li><li><a href="#page--module-build-and-starter--coding--PAGE" class="contents">8.3. Adding meaningful code</a>
+</li><li><a href="#page--module-build-and-starter--boilerplate--PAGE" class="contents">8.4. Getting rid of the boilerplate</a>
+</li><li><a href="#page--module-build-and-starter--additional-resources--PAGE" class="contents">8.5. Additional Resources</a>
+</li></ul>
+</li><li><a href="#page--conclusion--DIR" class="contents">9. Conclusion</a>
+<ul class="contents">
+<li><a href="#page--conclusion--links--PAGE" class="contents">9.1. Links</a>
+</li><li><a href="#page--conclusion--thanks--PAGE" class="contents">9.2. Thanks</a>
+</li></ul>
+</li></ul>
+<h2 id="licence">Licence</h2>
+<p>
+  <a rel="license" href="http://creativecommons.org/publicdomain/zero/1.0/" style="text-decoration:none;">
+    <img src="http://i.creativecommons.org/l/zero/1.0/80x15.png" alt="CC0" />
+  </a>
+  <br />
+  To the extent possible under law, <a href="http://www.shlomifish.org/" rel="dct:publisher"><span>Shlomi Fish</span></a>
+  has waived all copyright and related or neighboring rights to
+  <span>Perl for Perl Newbies</span>.
+This work is published from
+<span>Israel</span>.
+</p>
+<hr />
+
+</div>
+<div class="page">
+<table class="page-nav-bar top" summary=""><tr><td>
+<a href="#page--DIR" class="nav" accesskey="c">Contents</a></td>
+<td>
+<a href="#page--DIR" class="nav" accesskey="u">Up</a></td>
+<td>
+<a href="#page--DIR" class="nav" accesskey="p">Prev</a></td>
+<td>
+<a href="#page--testing--DIR" class="nav" accesskey="n">Next</a></td>
+</tr></table>
+<div class="bread">
+<a href="#page--DIR">"Perl for Perl Newbies" - Part 5 - Good Programming Practices</a> → <a href="#page--intro--PAGE">Introduction</a>
+</div>
+<h1 id="page--intro--PAGE">
+1. Introduction
+</h1>
+<p>
+We've already introduced some good
+<a href="http://en.wikipedia.org/wiki/Software_engineering">software
+engineering</a> practices in the previous lectures, but this lecture is
+going to contain a concentrated discussion of them. We will
+explain the motivation for their use, and show how to implement them,
+while giving some “hands-on” demonstrations.
+</p>
+<p>
+The mission of the Perl for Perl Newbies talks has been continued in our
+work on <a href="http://perl-begin.org/">The Perl Beginners' site</a>, which
+aims to be the premier web site for finding resources to learn about Perl.
+</p>
+<hr />
+
+</div>
+<div class="page">
+<table class="page-nav-bar top" summary=""><tr><td>
+<a href="#page--DIR" class="nav" accesskey="c">Contents</a></td>
+<td>
+<a href="#page--DIR" class="nav" accesskey="u">Up</a></td>
+<td>
+<a href="#page--intro--PAGE" class="nav" accesskey="p">Prev</a></td>
+<td>
+<a href="#page--testing--motivation--PAGE" class="nav" accesskey="n">Next</a></td>
+</tr></table>
+<div class="bread">
+<a href="#page--DIR">"Perl for Perl Newbies" - Part 5 - Good Programming Practices</a> → <a href="#page--testing--DIR">Automated Testing</a>
+</div>
+<h1 id="page--testing--DIR">
+2. Automated Testing
+</h1>
+<p>
+<a href="http://en.wikipedia.org/wiki/Test_automation">Automated testing</a>
+is a software engineering method in which one writes pieces of code, which
+in turn help us ascertain that the production code itself is functioning
+correctly. This section provides an introduction to automated software testing
+in Perl.
+</p>
+<ul class="contentsmain">
+<li><a href="#page--testing--motivation--PAGE" class="contents">2.1. Motivation for Testing</a>
+</li><li><a href="#page--testing--demo--DIR" class="contents">2.2. Demo</a>
+<ul class="contents">
+<li><a href="#page--testing--demo--test-more--PAGE" class="contents">2.2.1. Test::More</a>
+</li><li><a href="#page--testing--demo--Build-test--PAGE" class="contents">2.2.2. ./Build test</a>
+</li></ul>
+</li><li><a href="#page--testing--types--PAGE" class="contents">2.3. Types of Tests: Unit Tests, Integration Tests, System Tests</a>
+</li><li><a href="#page--testing--mocking--PAGE" class="contents">2.4. Mocking</a>
+</li></ul>
+<hr />
+
+</div>
+<div class="page">
+<table class="page-nav-bar top" summary=""><tr><td>
+<a href="#page--DIR" class="nav" accesskey="c">Contents</a></td>
+<td>
+<a href="#page--testing--DIR" class="nav" accesskey="u">Up</a></td>
+<td>
+<a href="#page--testing--DIR" class="nav" accesskey="p">Prev</a></td>
+<td>
+<a href="#page--testing--demo--DIR" class="nav" accesskey="n">Next</a></td>
+</tr></table>
+<div class="bread">
+<a href="#page--DIR">"Perl for Perl Newbies" - Part 5 - Good Programming Practices</a> → <a href="#page--testing--DIR">Automated Testing</a> → <a href="#page--testing--motivation--PAGE">Motivation for Testing</a>
+</div>
+<h1 id="page--testing--motivation--PAGE">
+2.1. Motivation for Testing
+</h1>
+<p>
+So why do we want to perform automated software testing? The
+first reason is to prevent bugs. By writing tests before we write the
+production code itself (so-called <b>Test-First Development</b>) we ascertain
+that the production code behaves according to the specification given in the
+tests. That way, bugs that could occur, if the code was deployed right away, or
+tested only manually, would be prevented.
+</p>
+<p>
+Another reason is to make sure that bugs and regressions are not
+reintroduced in the code-base. Say we have a bug, and we write a meaningful
+test that fails when the bug is still in the code, and only then fix the bug.
+In that case, we can re-use the test in the future to make sure the bug is not
+present in the current version of the code. If the bug re-surfaces in a certain
+variation, then it will likely be caught by the test.
+</p>
+<p>
+Finally, by writing tests we provide specifications to the code and even
+some form of API documentation, as well as examples of what we want the code
+to achieve. This causes less duplication than writing separate specification
+documents and examples, and, furthermore, is validated to be functional.
+</p>
+<hr />
+
+</div>
+<div class="page">
+<table class="page-nav-bar top" summary=""><tr><td>
+<a href="#page--DIR" class="nav" accesskey="c">Contents</a></td>
+<td>
+<a href="#page--testing--DIR" class="nav" accesskey="u">Up</a></td>
+<td>
+<a href="#page--testing--motivation--PAGE" class="nav" accesskey="p">Prev</a></td>
+<td>
+<a href="#page--testing--demo--test-more--PAGE" class="nav" accesskey="n">Next</a></td>
+</tr></table>
+<div class="bread">
+<a href="#page--DIR">"Perl for Perl Newbies" - Part 5 - Good Programming Practices</a> → <a href="#page--testing--DIR">Automated Testing</a> → <a href="#page--testing--demo--DIR">Demo</a>
+</div>
+<h1 id="page--testing--demo--DIR">
+2.2. Demo
+</h1>
+<p>
+Let's suppose we want to test a function that adds two numbers. (This is
+a classic example.) We have the following function in the module Add1.pm:
+</p>
+<div class="code_block"><pre>
+<span class="Statement">package</span><span class="Type"> Add1</span>;
+
+<span class="Statement">use strict</span>;
+<span class="Statement">use warnings</span>;
+
+<span class="Statement">use vars</span> <span class="Constant">qw(@EXPORT_OK @ISA)</span>;
+
+<span class="Statement">use </span>Exporter;
+
+<span class="Identifier">@ISA</span> = (<span class="Constant">qw(Exporter)</span>);
+
+<span class="Identifier">@EXPORT_OK</span> = (<span class="Constant">qw(add)</span>);
+
+<span class="Statement">sub </span><span class="Identifier">add</span>
+{
+    <span class="Statement">my</span> <span class="Identifier">$x</span> = <span class="Statement">shift</span>;
+    <span class="Statement">my</span> <span class="Identifier">$y</span> = <span class="Statement">shift</span>;
+
+    <span class="Statement">return</span> <span class="Constant">4</span>;
+}
+
+<span class="Constant">1</span>;
+</pre></div>
+<p>
+One way to write a rudimentary script to test it, would be the following:
+</p>
+<div class="code_block"><pre>
+<span class="PreProc">#!/usr/bin/perl</span>
+
+<span class="Statement">use strict</span>;
+<span class="Statement">use warnings</span>;
+
+<span class="Statement">use </span>Add1 (<span class="Constant">qw(add)</span>);
+
+<span class="Statement">if</span> (!(add(<span class="Constant">2</span>,<span class="Constant">2</span>) == <span class="Constant">4</span>))
+{
+    <span class="Statement">die</span> <span class="Constant">&quot;add(2,2) failed&quot;</span>;
+}
+<span class="Statement">exit</span>(<span class="Constant">0</span>);
+</pre></div>
+<p>
+This script will die with an ugly exception if adding 2 and 2 failed and
+quietly exit with a success code if everything is OK. Let's run it:
+</p>
+<div class="code_block"><pre>
+$ perl add1-test.pl
+$
+</pre></div>
+<p>
+Everything is OK. Now let's write another test:
+</p>
+<div class="code_block"><pre>
+<span class="PreProc">#!/usr/bin/perl</span>
+
+<span class="Statement">use strict</span>;
+<span class="Statement">use warnings</span>;
+
+<span class="Statement">use </span>Add1 (<span class="Constant">qw(add)</span>);
+
+<span class="Statement">if</span> (!(add(<span class="Constant">2</span>,<span class="Constant">2</span>) == <span class="Constant">4</span>))
+{
+    <span class="Statement">die</span> <span class="Constant">&quot;add(2,2) failed&quot;</span>;
+}
+
+{
+    <span class="Statement">my</span> <span class="Identifier">$result</span> = add(<span class="Constant">1</span>,<span class="Constant">1</span>);
+
+    <span class="Statement">if</span> (<span class="Identifier">$result</span> != <span class="Constant">2</span>)
+    {
+        <span class="Statement">die</span> <span class="Constant">&quot;add(1,1) resulted in '</span><span class="Identifier">$result</span><span class="Constant">' instead of 2.&quot;</span>
+    }
+}
+
+<span class="Statement">exit</span>(<span class="Constant">0</span>);
+</pre></div>
+<p>
+This time the test fails:
+</p>
+<div class="code_block"><pre>
+$ perl add1-test-2.pl
+add(1,1) resulted in '4' instead of 2. at add1-test-2.pl line 18.
+$
+</pre></div>
+<p>
+As a result, we need to fix the production code:
+</p>
+<div class="code_block"><pre>
+<span class="Statement">package</span><span class="Type"> Add2</span>;
+
+<span class="Statement">use strict</span>;
+<span class="Statement">use warnings</span>;
+
+<span class="Statement">use vars</span> <span class="Constant">qw(@EXPORT_OK @ISA)</span>;
+
+<span class="Statement">use </span>Exporter;
+
+<span class="Identifier">@ISA</span> = (<span class="Constant">qw(Exporter)</span>);
+
+<span class="Identifier">@EXPORT_OK</span> = (<span class="Constant">qw(add)</span>);
+
+<span class="Statement">sub </span><span class="Identifier">add</span>
+{
+    <span class="Statement">my</span> <span class="Identifier">$x</span> = <span class="Statement">shift</span>;
+    <span class="Statement">my</span> <span class="Identifier">$y</span> = <span class="Statement">shift</span>;
+
+    <span class="Statement">return</span> <span class="Identifier">$x</span>+<span class="Identifier">$y</span>;
+}
+
+<span class="Constant">1</span>;
+</pre></div>
+<p>
+And the equivalent test script is successful:
+</p>
+<div class="code_block"><pre>
+<span class="PreProc">#!/usr/bin/perl</span>
+
+<span class="Statement">use strict</span>;
+<span class="Statement">use warnings</span>;
+
+<span class="Statement">use </span>Add2 (<span class="Constant">qw(add)</span>);
+
+<span class="Statement">if</span> (!(add(<span class="Constant">2</span>,<span class="Constant">2</span>) == <span class="Constant">4</span>))
+{
+    <span class="Statement">die</span> <span class="Constant">&quot;add(2,2) failed&quot;</span>;
+}
+
+{
+    <span class="Statement">my</span> <span class="Identifier">$result</span> = add(<span class="Constant">1</span>,<span class="Constant">1</span>);
+
+    <span class="Statement">if</span> (<span class="Identifier">$result</span> != <span class="Constant">2</span>)
+    {
+        <span class="Statement">die</span> <span class="Constant">&quot;add(1,1) resulted in '</span><span class="Identifier">$result</span><span class="Constant">' instead of 2.&quot;</span>
+    }
+}
+
+<span class="Statement">exit</span>(<span class="Constant">0</span>);
+</pre></div>
+<p>
+Now we can continue writing more tests, and see that they passed.
+</p>
+<ul class="contentsmain">
+<li><a href="#page--testing--demo--test-more--PAGE" class="contents">2.2.1. Test::More</a>
+</li><li><a href="#page--testing--demo--Build-test--PAGE" class="contents">2.2.2. ./Build test</a>
+</li></ul>
+<hr />
+
+</div>
+<div class="page">
+<table class="page-nav-bar top" summary=""><tr><td>
+<a href="#page--DIR" class="nav" accesskey="c">Contents</a></td>
+<td>
+<a href="#page--testing--demo--DIR" class="nav" accesskey="u">Up</a></td>
+<td>
+<a href="#page--testing--demo--DIR" class="nav" accesskey="p">Prev</a></td>
+<td>
+<a href="#page--testing--demo--Build-test--PAGE" class="nav" accesskey="n">Next</a></td>
+</tr></table>
+<div class="bread">
+<a href="#page--DIR">"Perl for Perl Newbies" - Part 5 - Good Programming Practices</a> → <a href="#page--testing--DIR">Automated Testing</a> → <a href="#page--testing--demo--DIR">Demo</a> → <a href="#page--testing--demo--test-more--PAGE">Test::More</a>
+</div>
+<h1 id="page--testing--demo--test-more--PAGE">
+2.2.1. Test::More
+</h1>
+<p>
+Perl ships with a module called Test::More (which is part of the
+<a href="http://search.cpan.org/dist/Test-Simple/">Test-Simple CPAN
+distribution</a>, which may be more up-to-date there), that allows one
+to write and run tests using convenient functions. Here's an example
+for a test script:
+</p>
+<div class="code_block"><pre>
+<span class="PreProc">#!/usr/bin/perl</span>
+
+<span class="Statement">use strict</span>;
+<span class="Statement">use warnings</span>;
+
+<span class="Statement">use </span>Test::More <span class="Constant">tests</span> =&gt; <span class="Constant">7</span>;
+
+<span class="Statement">use </span>Add2 (<span class="Constant">qw(add)</span>);
+
+<span class="Comment"># TEST</span>
+is (add(<span class="Constant">0</span>, <span class="Constant">0</span>),
+    <span class="Constant">0</span>,
+    <span class="Constant">&quot;0+0 == 0&quot;</span>,
+);
+
+<span class="Comment"># TEST</span>
+is (add(<span class="Constant">2</span>, <span class="Constant">2</span>),
+    <span class="Constant">4</span>,
+    <span class="Constant">&quot;2+2 == 4&quot;</span>,
+);
+
+<span class="Comment"># TEST</span>
+is (add(<span class="Constant">4</span>, <span class="Constant">20</span>),
+    <span class="Constant">24</span>,
+    <span class="Constant">&quot;4+20 == 24&quot;</span>,
+);
+
+<span class="Comment"># TEST</span>
+is (add(<span class="Constant">20</span>, <span class="Constant">4</span>),
+    <span class="Constant">24</span>,
+    <span class="Constant">&quot;20+4 == 24&quot;</span>,
+);
+
+<span class="Comment"># TEST</span>
+is (add(-<span class="Constant">2</span>, <span class="Constant">8</span>),
+    <span class="Constant">6</span>,
+    <span class="Constant">&quot;(-2)+8 == 6&quot;</span>,
+);
+
+<span class="Comment"># TEST</span>
+is (add(<span class="Constant">4</span>, <span class="Constant">3.5</span>),
+    <span class="Constant">7.5</span>,
+    <span class="Constant">&quot;4+3.5 == 7.5&quot;</span>,
+);
+
+<span class="Comment"># TEST</span>
+is (add(<span class="Constant">3.5</span>, <span class="Constant">3.5</span>),
+    <span class="Constant">7</span>,
+    <span class="Constant">&quot;3.5+3.5 == 7&quot;</span>
+);
+</pre></div>
+<p>
+<tt>is()</tt> is a Test-More built-in that compares a received result ("have")
+to an expected result ("want") for exact equivalence. There are also
+<tt>ok()</tt>, which just tests for truthhood, <tt>is_deeply()</tt> which
+performs a deep comparison of nested data structures, and others.
+</p>
+<p>
+You may also notice the <tt># TEST</tt> comments - these are
+<a href="http://search.cpan.org/dist/Test-Count/">Test::Count</a> annotations
+that allow us to keep track of the number of test assertions that we have
+declared and update it.
+</p>
+<p>
+Now, the output of this would be:
+</p>
+<div class="code_block"><pre>
+1..7
+ok 1 - 0+0 == 0
+ok 2 - 2+2 == 4
+ok 3 - 4+20 == 24
+ok 4 - 20+4 == 24
+ok 5 - (-2)+8 == 6
+ok 6 - 4+3.5 == 7.5
+ok 7 - 3.5+3.5 == 7
+</pre></div>
+<p>
+This is in an output format called <a href="http://testanything.org/">TAP - The
+Test Anything Protocol</a>. There are several TAP parsers, which analyse the
+output and present a human-friendly summary. For example, we can run the test
+script above using the <tt>prove</tt> command-line utility that ships with
+perl 5:
+</p>
+<div class="code_block"><pre>
+$ prove Test-More-1.t
+Test-More-1.t .. ok
+All tests successful.
+Files=1, Tests=7,  0 wallclock secs ( 0.06 usr  0.01 sys +  0.06 cusr  0.01 csys =  0.14 CPU)
+Result: PASS
+</pre></div>
+<p>
+For more information refer to the following sources:
+</p>
+<ol>
+<li>
+<a href="http://search.cpan.org/perldoc?Test%3A%3ATutorial">Test::Tutorial on the
+CPAN</a>
+</li>
+<li>
+<a href="http://szabgab.com/talks/perl_in_testing/">"Testing with Perl" by
+Gabor Szabo</a> - comprehensive material of a talk about Perl and testing.
+</li>
+<li>
+<a href="http://search.cpan.org/dist/Test-Count/">Test::Count</a> - allows
+one to keep track of the number of assertions in the test file.
+</li>
+<li>
+<a href="http://web-cpan.shlomifish.org/modules/Test-Run/">Test-Run</a> - an
+alternative test harness under development (with output in colour and other
+enhancements).
+</li>
+<li>
+<a href="http://qa.perl.org/">The Perl Quality Assurance (QA) Project</a>.
+</li>
+</ol>
+<hr />
+
+</div>
+<div class="page">
+<table class="page-nav-bar top" summary=""><tr><td>
+<a href="#page--DIR" class="nav" accesskey="c">Contents</a></td>
+<td>
+<a href="#page--testing--demo--DIR" class="nav" accesskey="u">Up</a></td>
+<td>
+<a href="#page--testing--demo--test-more--PAGE" class="nav" accesskey="p">Prev</a></td>
+<td>
+<a href="#page--testing--types--PAGE" class="nav" accesskey="n">Next</a></td>
+</tr></table>
+<div class="bread">
+<a href="#page--DIR">"Perl for Perl Newbies" - Part 5 - Good Programming Practices</a> → <a href="#page--testing--DIR">Automated Testing</a> → <a href="#page--testing--demo--DIR">Demo</a> → <a href="#page--testing--demo--Build-test--PAGE">./Build test</a>
+</div>
+<h1 id="page--testing--demo--Build-test--PAGE">
+2.2.2. ./Build test
+</h1>
+<p>
+Standard CPAN and CPAN-like Perl packages contain their tests as a group
+of <tt>*.t</tt> under the sub-directory <tt>t/</tt>, and allow running them
+by invoking the <tt>make test</tt> or <tt>./Build test</tt> commands.
+</p>
+<p>
+Using the CPAN package
+<a href="http://search.cpan.org/dist/Module-Starter/">Module-Starter</a>
+one can generate a skeleton for one’s own CPAN-like package, which
+can also afterwards contain tests. Keeping your code organised in such packages,
+allows one to make use of a convenient build-system
+such as <a href="http://search.cpan.org/dist/Module-Build/">Module-Build</a>.
+It also allows one to package it as operating-system-wide packages, which can
+be removed easily using the system's package manager. Finally, these packages
+can later be uploaded to CPAN for sharing with other users and developers.
+</p>
+<p>
+Here’s an example of testing a CPAN distribution from CPAN using
+<tt>./Build test</tt>:
+</p>
+<div class="code_block"><pre>
+shlomi:~/TEMP$ ls
+shlomi:~/TEMP$ mv ~/Test-Count-0.0500.tar.gz .
+shlomi:~/TEMP$ ls
+Test-Count-0.0500.tar.gz
+shlomi:~/TEMP$ ls -l
+total 16
+-rw-r--r-- 1 shlomi shlomi 12933 2009-08-02 20:52 Test-Count-0.0500.tar.gz
+shlomi:~/TEMP$ tar -xvf Test-Count-0.0500.tar.gz
+Test-Count-0.0500
+Test-Count-0.0500/Changes
+Test-Count-0.0500/MANIFEST
+Test-Count-0.0500/META.yml
+Test-Count-0.0500/Build.PL
+Test-Count-0.0500/Makefile.PL
+Test-Count-0.0500/README
+Test-Count-0.0500/t
+Test-Count-0.0500/t/boilerplate.t
+Test-Count-0.0500/t/03-filter.t
+Test-Count-0.0500/t/01-parser.t
+Test-Count-0.0500/t/pod-coverage.t
+Test-Count-0.0500/t/02-main.t
+Test-Count-0.0500/t/00-load.t
+Test-Count-0.0500/t/pod.t
+Test-Count-0.0500/t/sample-data
+Test-Count-0.0500/t/sample-data/test-scripts
+Test-Count-0.0500/t/sample-data/test-scripts/arithmetics.t
+Test-Count-0.0500/t/sample-data/test-scripts/01-parser.t
+Test-Count-0.0500/t/sample-data/test-scripts/basic.arc
+Test-Count-0.0500/examples
+Test-Count-0.0500/examples/perl-test-manage-helper.pl
+Test-Count-0.0500/examples/perl-test-manage.vim
+Test-Count-0.0500/lib
+Test-Count-0.0500/lib/Test
+Test-Count-0.0500/lib/Test/Count.pm
+Test-Count-0.0500/lib/Test/Count
+Test-Count-0.0500/lib/Test/Count/Base.pm
+Test-Count-0.0500/lib/Test/Count/Parser.pm
+Test-Count-0.0500/lib/Test/Count/Filter.pm
+Test-Count-0.0500/lib/Test/Count/Filter
+Test-Count-0.0500/lib/Test/Count/Filter/ByFileType
+Test-Count-0.0500/lib/Test/Count/Filter/ByFileType/App.pm
+Test-Count-0.0500/inc
+Test-Count-0.0500/inc/Test
+Test-Count-0.0500/inc/Test/Run
+Test-Count-0.0500/inc/Test/Run/Builder.pm
+shlomi:~/TEMP$ cd Test
+Test-Count-0.0500/        Test-Count-0.0500.tar.gz
+shlomi:~/TEMP$ cd Test-Count-0.0500
+shlomi:~/TEMP/Test-Count-0.0500$ ls
+Build.PL  examples  lib          MANIFEST  README
+Changes   inc       Makefile.PL  META.yml  t
+shlomi:~/TEMP/Test-Count-0.0500$ perl Build.PL
+Checking whether your kit is complete...
+Looks good
+
+Checking prerequisites...
+Looks good
+
+Creating new 'Build' script for 'Test-Count' version '0.0500'
+shlomi:~/TEMP/Test-Count-0.0500$ ./Build
+Copying lib/Test/Count/Filter/ByFileType/App.pm -&gt; blib/lib/Test/Count/Filter/ByFileType/App.pm
+Copying lib/Test/Count/Base.pm -&gt; blib/lib/Test/Count/Base.pm
+Copying lib/Test/Count/Filter.pm -&gt; blib/lib/Test/Count/Filter.pm
+Copying lib/Test/Count/Parser.pm -&gt; blib/lib/Test/Count/Parser.pm
+Copying lib/Test/Count.pm -&gt; blib/lib/Test/Count.pm
+Manifying blib/lib/Test/Count/Parser.pm -&gt; blib/libdoc/Test::Count::Parser.3pm
+Manifying blib/lib/Test/Count/Base.pm -&gt; blib/libdoc/Test::Count::Base.3pm
+Manifying blib/lib/Test/Count.pm -&gt; blib/libdoc/Test::Count.3pm
+Manifying blib/lib/Test/Count/Filter/ByFileType/App.pm -&gt; blib/libdoc/Test::Count::Filter::ByFileType::App.3pm
+Manifying blib/lib/Test/Count/Filter.pm -&gt; blib/libdoc/Test::Count::Filter.3pm
+shlomi:~/TEMP/Test-Count-0.0500$ ./Build test
+t/00-load.t ....... 1/3 # Testing Test::Count 0.0500, Perl 5.010000, /usr/bin/perl5.10.0
+t/00-load.t ....... ok
+t/01-parser.t ..... ok
+t/02-main.t ....... ok
+t/03-filter.t ..... ok
+t/boilerplate.t ... ok
+t/pod-coverage.t .. ok
+t/pod.t ........... ok
+All tests successful.
+Files=7, Tests=30,  4 wallclock secs ( 0.12 usr  0.03 sys +  2.59 cusr  0.19 csys =  2.93 CPU)
+Result: PASS
+shlomi:~/TEMP/Test-Count-0.0500$
+</pre></div>
+<hr />
+
+</div>
+<div class="page">
+<table class="page-nav-bar top" summary=""><tr><td>