<?xml version="1.0" encoding="ISO-8859-1"?>
<screenbook>
<title realName="B8 Perl Utilities">Perl Utilities</title>
<category realName="Leo">Leo</category>
<subcategory realName="Examples">Examples</subcategory>
<format realName="Tutorial">Tutorial</format>
<description></description>
<keywords></keywords><ldate>8/4/2002</ldate><version>draft</version>
<locations>
<location>
C:\testtt\Leo\Examples\Tutorials\B8 Perl Utilities\</location>

</locations>

<pages>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Perl is a great language for many things, but one thing it really shines at is in making small programs for system administration. There is a huge library of components for system administration that you can use from Perl, and it is easy to do a lot with a small script.</p><p>Scripts that are dashed off quickly to take care of&#160;small tasks tend not to be terribly readable and well documented, particularly in a language like Perl that has so many ways to pack a lot of functionality into a few statements. Such scripts also tend to proliferate, since often it can be faster to write a new script than find out whether a script already exists that can do the job.</p><p>This tutorial provides an example of how using Leo can solve both of these problems. One sample script is presented, but it is easy to see how adding more scripts to this example outline could result in a package that is very well documented. Addind a new script to&#160;this outline would not&#160;take&#160;much more effort than dashing off a script in a standard text editor.</p>]]></span>

</text>
<picture>[Empty]</picture>
<title>A Perl Example</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>The&#160;Leo file used in this tutorial&#160;is available from my <a href="http://www.jserv.com/jk_orr/xml/leo.htm">Leo Resource Page</a>. To download it <a href="http://www.jserv.com/jk_orr/xml/driveinfo.leo">right-click on this link</a> and choose "Save Target".</p><p>Here is how the file looks when first opened.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic02.png</picture>
<title>The driveinfo.leo file</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>The <strong>driveinfo.leo</strong> file contains a single script, with documentation and other supplementary files. The script in <strong>driveinfo.leo</strong> is <strong>driveinfo.pl</strong> , a Perl script for checking drive space on a Windows machine and then emailing this information to any number of people. (This script doesn't use the newest modules, so it may not be useful for deployment at this point, but still can serve as an illustration of Leo's capability).</p><p>If you've downloaded the file and are investigating it with Leo now, you can quickly see that the Leo outline clearly shows what the program is, how to use it, and how it is programmed. Since the benefits of such an outline will probably be immediately obvious, this tutorial will not go into much detail, but will simply point out a few features of the outline.</p>]]></span>

</text>
<picture>[Empty]</picture>
<title>driveinfo.pl</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<ol> <li/>The first node of the outline explains what is in the outline and how to use it. <li/> This node has info about installing the modules necessary to run this script. Most scripts&#160;use Perl modules, and not everyone will know how to get and install a Perl module <li/>This node has the actual script. </ol>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic04.png</picture>
<title>Some example nodes</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Users of the script will not need to look at the script node, since documentation of how to use it is contained in other nodes. Only progammers who want to change the script will be interested in opening the script node and looking at it.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic05.png</picture>
<title>The documentation and script nodes</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>The Driveinfo script is broken down into four sections plus a section for functions. The indicated node is where the script reads the drive space of the drives on the current machine.</p><p>Some people claim that Perl is hard to read, but anyone with a basic knowledge of Perl should find the code in this node to be simple to understand.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic06.png</picture>
<title>The Driveinfo script has four sections</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Leo not only makes it easy to deploy a program, it makes it easy to study the program to learn how to implement a particular feature. Let's suppose we aren't interested in drive space, but we do want to write a script to send email. That information is obviously going to be in the indicated node.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic07.png</picture>
<title>Studying the code</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>But apparently that functionality is implemented in the <strong>&amp;notify</strong> function. We'll have to find and look at that.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic08.png</picture>
<title>The notify function</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Since it is a function, we'll expect to find it in this node.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic09.png</picture>
<title>The function node</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>The entire function is displayed in the body pane. This is all the code we need to send email using Perl and SMTP module.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic10.png</picture>
<title>The entire function is displayed in the body pane.</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
</pages>
</screenbook>


