<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="http://starling.us/gus_xslt.xsl"?>
<gus_xslt
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://starling.ws/XML/gus_xslt.xsd">
<head>
  <navigation ToC="Table of Contents" 
    section="yes" topic="yes" subtopic="yes" subsubtopic="yes" links="yes"/>
  <syndication atom="http://starling.us/starling_us_atom.xml" />
  <cgi img="no" img_action="../cgi-bin/gus_web_photo.pl" img_path="../gus_calc_generic_pl" />
  <pdfmarks body="no" section="no" topic="no" subtopic="no" subsubtopic="no"/>
  <title>Perl Script</title>
  <description>Perl Script</description>
  <keywords>Perl, Starling</keywords>
  <author>Gan Uesli Starling</author>
  <copyright>2007, Gan Uesli Starling</copyright>
</head>
<body>
  <title>Perl Script <code>gus_calc_generic.pl</code></title>
  <p class="center" style="line-height:150%;">copyright 2007<br/>by Ĝan Ŭesli Starling</p>

  <section>
    <title>Introduction</title>
    <p>I find it annoying to receive a report which has all of its useful conclusions sequestered into separate files in disparate formats such that one must juggle several windows in order to extract said report's essential content. I would very much prefer to view said info presented concisely and neatly within but a single on-screen window. Ideally I'd like to see: description first, conclusion second, supporting arguments and data nested hierarchically beneath those two. And if there be links strewn all about therein, so that I might hop back and forth at will, so much the better.</p>
    <p>On such occasions as when I have presented my own documentation that way, requestors have recieved them gladly. In those cases I will have compiled the whole report into true electronic format, which is to say XML, not PDF. There will be an <code>index.xml</code> page and a directory <code>report_files</code> containing all the support documents, graphics, etc. If the report need be sent off site, then I just <code>zip</code> it up and attach to an e-mail with a note to <code>unzip</code> it anywhere and open the <code>index.xml</code> in any browser.</p>
    <p>Why not PDF? Well... The way most people use PDF is to digitize paper docs for electronic storage. Personally, I hate receiving those as they are never truly convenient to peruse electonically. Viewing them on-screen at page width interrupts the vertical scroll with every page break. Annoying, that. Viewing them at page height wastes screen space and makes the font tiny. Hard to read, even more annoying yet. In this electronic age the whole idea of <i>pages</i> is antiquated, utterly non-sequitur. At home I don't even own a printer. Thus my preference for an endless vertical scroll. I write XML docs in just this fashion with countless embeded browsing links all self-generating care of the magic of XSLT. Ref: <a class="button" href="http://starling.us/xml/">XML</a></p>    
  </section>
  
  <section>
    <title>Avoiding Spreadsheets</title>
    <p>Toward that end I seek to largely abandon any presentation format which is not viewable in any browser on any platform. This is a little script to help meet that goal by automating one of my editing steps. For simple data it permits one to forgoe any recourse to spreadsheets. Performing spreadsheet-like functions embeded within plain ASCII CSV input files it gives similarly plain ASCII CSV output importable into text editors, XML/HTML documents (like this one) and the like.</p>
    <p>Suppose, for example, you have an existing spreadsheet form, one out on a factory floor someplace into which operators type results...or scribble results onto a printed version thereof. And suppose that your document looks someting like this...</p>
   
<pre>   
# These are pseudo flow data from a hypothetical spray nozzle.
# Data are deliberately contrived so as to fail certain of the test
# conditions as an exercise of a parsing/munging script written in Perl.
 
   PSIG (UOS), 30 (dpm), 50 (dpm),   60,      80,         100,         120,         130,     170,     320,         400,     560,  170 Hyst 3%
 Limits Tight,      &gt;50,      &gt;70,   &lt;3, 4.5~7.5, record only, record only, record only, 154~165, 431~466, record only, 745~780,  97%~103% (170)
 Limits Slack,   record,      &gt;80,   &lt;2, 4.0~8.0,      record,      ignore,        skip, 150~169, 421~476, record only, 730~795,  95%~105% (170)
   Data So-so,       45,       50,  3.2,     7.1,        15.3,        16.8,        22.6,   159.6,   469.2,       586.2,   771.4,  159
   Data Worse,       55,       75,  1.7,     7.7,        61.6,        64.9,        71.4,     184,   465.5,       573.3,   760.6,  184
</pre>
    
    <p>Not exactly like that, but that general kind of layout where...</p>
    
    <ul>
      <li>The first (top) line lists the names of various, possibly unrelated, sets of conditions.</li>
      <li>The 2nd thru Nth lines (those with ~, &gt; and &lt; symbols) are acceptance criteria.</li>
      <li>The Nth+1 and lower lines are data sets.</li>
    </ul>
    
    <p>And say you want the each data set applied to each acceptance criteria. And say also that, for whatever reasons, you don't care to use an actual spreadsheet, but would prefer plain ASCII. That is the purpose of this script. The above data will give an output which looks like this...</p>
    
<pre>

Report generated by Perl script:
  'J:/gus_perl/gus_calc_generic_pl/gus_calc_generic.pl' version 0.05 
Input data read from:
  'Psuedo_PPH_Flow_Record_0.csv'

# These are pseudo flow data from the metering set of a spray nozzle

  PSIG (UOS), 30 (dpm), 50 (dpm),     60,            80,           100,           120,           130,           170,           320,           400,           560,    170 Hyst 3%,    Combined

Limits Tight,   ? &lt; 50,   ? &lt; 70,  ? &gt; 3, 4.5 &lt; ? &lt; 7.5, 'record only', 'record only', 'record only', 154 &lt; ? &lt; 165, 431 &lt; ? &lt; 466, 'record only', 745 &lt; ? &lt; 780, 97% &lt; ? &lt; 103%,      Results
  Data So-so,       45,       50,    3.2,           7.1,          15.3,          16.8,          22.6,         159.6, <span style="color:red;font-weight:bold;">(*)     469.2</span>,         586.2,         771.4,            159,   1 FAILURE!
  Data Worse, <span style="color:red;font-weight:bold;">(*)   55</span>, <span style="color:red;font-weight:bold;">(*)   75</span>, (*)1.7, <span style="color:red;font-weight:bold;">(*)       7.7</span>,          61.6,          64.9,          71.4, <span style="color:red;font-weight:bold;">(*)       184</span>,         465.5,         573.3,         760.6,            184,  5 FAILURES!

Limits Slack, 'record',   ? &lt; 80,  ? &gt; 2, 4.0 &lt; ? &lt; 8.0,      'record',      'ignore',        'skip', 150 &lt; ? &lt; 169, 421 &lt; ? &lt; 476, 'record only', 730 &lt; ? &lt; 795, 95% &lt; ? &lt; 105%,      Results
  Data So-so,       45,       50,    3.2,           7.1,          15.3,          16.8,          22.6,         159.6,         469.2,         586.2,         771.4,            159,         PASS
  Data Worse,       55,       75, (*)1.7,           7.7,          61.6,          64.9,          71.4, <span style="color:red;font-weight:bold;">(*)       184</span>,         465.5,         573.3,         760.6,            184,  2 FAILURES!
</pre>


<p>Below is precisely same table as above but rotated 90 degrees and re-grouped into sets by test range.
</p>

<pre>
   PSIG (UOS)    Limits Tight,  Data So-so,   Data Worse
     30 (dpm)          ? &lt; 50,          45, <span style="color:red;font-weight:bold;">(*)       55</span>
     50 (dpm)          ? &lt; 70,          50, <span style="color:red;font-weight:bold;">(*)       75</span>
           60           ? &gt; 3,         3.2, <span style="color:red;font-weight:bold;">(*)      1.7</span>
           80   4.5 &lt; ? &lt; 7.5,         7.1, <span style="color:red;font-weight:bold;">(*)      7.7</span>
          100   'record only',        15.3,         61.6
          120   'record only',        16.8,         64.9
          130   'record only',        22.6,         71.4
          170   154 &lt; ? &lt; 165,       159.6, <span style="color:red;font-weight:bold;">(*)      184</span>
          320   431 &lt; ? &lt; 466, <span style="color:red;font-weight:bold;">(*)   469.2</span>,        465.5
          400   'record only',       586.2,        573.3
          560   745 &lt; ? &lt; 780,       771.4,        760.6
  170 Hyst 3%  97% &lt; ? &lt; 103%,         159,          184
     Combined         Results,  1 FAILURE!,  5 FAILURES!


   PSIG (UOS)    Limits Slack,  Data So-so,   Data Worse,
     30 (dpm)        'record',          45,           55,
     50 (dpm)          ? &lt; 80,          50,           75,
           60           ? &gt; 2,         3.2, <span style="color:red;font-weight:bold;">(*)      1.7</span>,
           80   4.0 &lt; ? &lt; 8.0,         7.1,          7.7,
          100        'record',        15.3,         61.6,
          120        'ignore',        16.8,         64.9,
          130          'skip',        22.6,         71.4,
          170   150 &lt; ? &lt; 169,       159.6, <span style="color:red;font-weight:bold;">(*)      184</span>,
          320   421 &lt; ? &lt; 476,       469.2,        465.5,
          400   'record only',       586.2,        573.3,
          560   730 &lt; ? &lt; 795,       771.4,        760.6,
  170 Hyst 3%  95% &lt; ? &lt; 105%,         159,          184,
     Combined         Results,        PASS,  2 FAILURES!,
</pre>

  <topic>
    <title>Dual Orientations</title>
    <p>Note how it provides the results oriented two ways. First is the same orientation as given by the source file. Secondly it gives a 90-degree matrix rotation of that same table. Depending on how you prefer to present your results, choose either...or both.</p>
  </topic>
  
  <topic>
    <title>Dual Formats</title>
     <p>Also note, when you open the actual ASCII output file, that the tables included there are even more redundant yet. The above two kinds of tables are presented each in formats, plain ASCII and HTML-ified. The latter format is identical to the former except for two distinctions:</p>
     <ul>
       <li>Three symbols have been escaped for XML/HTML: <code>&lt;</code>, <code>&gt;</code> and <code>&amp;</code>.</li>
       <li>Failures conditions have been highlighted using <code>&gt;span&lt;</code> nodes having style attributes.</li>
     </ul>
    <p>This page being XML, I perforce must display only the escaped renditions.</p>
  </topic>

  </section>
  
  <section>
    <title>Download</title>
    
    <p>My script <code>gus_calc_generic.pl</code> will process pure ASCII input tables and formulae very like spreadsheet, but with output to pure ASCII <code>*.csv</code> format. Although this script has no built-in GUI, a separate GUI is also provided in its own pair of download links.</p>
    
    <p>Remember to edit the extension from <code>*.txt</code> to <code>*.pl</code> after downloading a Perl script. Likewise from <code>*.txt</code> to <code>*.CSV</code> after downloading a Tektroni CSV file. The <code>*.txt</code> extension is necessary to insure that the web server will present these files to you as plain ASCII when you click their download buttons.</p>
    
    <!--
    
    Dear Maintainer,
    
    Please note! Within the original maintenance directory, the *.txt extensions are not used.
    Therein the original, bare *.pl and *.csv extensions are in force. So perform uploads to
    any web servers via FTP as below...
    
    ftp> put foo.pl foo.pl.txt
    ftp> put foo.csv foo.csv.txt
    
    ...and so forth or the download links in this text will break.
    
    -->

    <topic>
      <title>Scripts</title>
      <p>Here are links relating to the command-line version of this script.</p>
      
<p><code>Script:&#160;</code>
<a class="button" href="./gus_calc_generic.html">POD as HTML</a>
&#160;
<a class="button" href="./gus_calc_generic.txt">Perl as TXT</a>
</p>
    </topic> 
    
    <topic>
      <title>Auxilliary GUI</title>
      <p>Here is the separate GUI, written in Perl/Tk which will interface to (call and run on command) the above GUI-less Perl script. This is my new methodology for dealing with simple scripts, rather than build in a custom GUI for each.</p>

<p><code>Script:&#160;</code>
<a class="button" href="./gus_calc_generic_EasyGUI.html">POD as HTML</a>
&#160;
<a class="button" href="./gus_calc_generic_EasyGUI.txt">Perl as TXT</a>
</p>
    </topic> 
    
    <topic>
      <title>Example CSV Files</title>
      <p>To test the above script (with or without its GUI) you will need at least one example test-criteria/test-data file. Here is a pair of such for you to play with.</p>

<p><code>Inputs:&#160;</code>
<a class="button" href="./Pseudo_PPH_Flow_Record_0.txt">CSV as TXT</a>
&#160;
<a class="button" href="./Pseudo_PPH_Flow_Record_1.txt">CSV as TXT</a>
</p>
    </topic> 
    
    <topic>
      <title>Custom Dependencies</title>
      <p>This script has a Perl module dependency not yet on CPAN. Download it from here.</p>
    
<p><code>Module:&#160;</code>
<a class="button" href="../gus_perl_modules/index.xml#Tk-EasyGUI">XML</a> 
&#160;<code>Tk::EasyGUI</code>
</p>
    </topic> 
    
  </section>
  
  
</body>
</gus_xslt>
