# Perl Source Code

## Description

I plan to move all of this to {{< snippet "jp-github" >}} at some point...

When saving, rename from *.pl.txt to *.pl or whatever you use for Perl.
If using on Unix, you may need to convert CRLF to LF, and modify
the "shebang" line (e.g. \#\!/usr/local/bin). "[CleanUp](/public/source/cleanup.pl.txt)"
can fix the line termination. Or find a good `dos2unix` and `unix2dos`
program like those found in the *[UNXUtils](http://unxutils.sourceforge.net/)*.

Perl (Practical Extraction and Report Language or Pathologically
Eclectic Rubbish Lister) is an interpreted language optimized for
scanning arbitrary text files, extracting information from those text
files, and printing reports based on that information. It's also a good
language for many system management tasks. Start at
*[www.perl.com](http://www.perl.com/)*, and check *[getting the latest
Perl](http://www.perl.com/pub/a/language/info/software.html)*. See the
Win32 section especially if you use Win95 or WinNT (Hint: these versions
can access the NT event logs, making collection and auditing them
**much** easier...). I use
*[ActiveState's](http://www.ActiveState.com/)*
*[ActivePerl](http://www.activestate.com/Products/ActivePerl/index.html)*.
I've also used *[IndigoStar's](http://www.indigostar.com/)*
*[IndigoPerl](http://www.indigostar.com/indigoperl.htm)* (which has
*[Apache](http://www.apache.org/)* built in) and
*[Perl2Exe](http://www.indigostar.com/perl2exe.htm)* which can "compile"
Perl. And check out the *[Open Perl
IDE](http://open-perl-ide.sourceforge.net/)*.

-----

## Scripts

**Clicking on the name of a script will open the code here, so you probably
want to open ina a new tab instead.**


[CleanUp](/public/source/cleanup.pl.txt) v1.9 2002-10-06
: General purpose utility to clean up messy text files. Can convert
  tabs (see Tab above), UPPER or lower case the entire file, remove
  leading "\>", trim, convert CRLF \<--\> LF, number output, etc.
  Ironocally, the code for this is very messy too. One of these days I
  need to start fresh, but...

[CSV2html](/public/source/csv2html.pl.txt) v2.3 2005-10-07
: Turn a csv file into a simple HTML table. (Similar to
  HTMLTable.pl)

[CSV2tab](/public/source/csv2tab.pl.txt) v3.5 2008-09-27
: Convert CSV files to TAB delimited files.

[DNSLookup.pl](/public/source/DNSLookup.pl.txt) 1.0 2002-11-22
" Lookup IPAs and get hostnames from STDIN or a file.

[DoMath](/public/source/domath.pl.txt) v1.2 2002-10-22
: Perform math operations on arbitrary lines of numerical input

[GenFiles](/public/source/genfiles.pl.txt) v1.0 1998-03-07
: Creates files of a certain size for testing purposes.

[GenPass](/public/source/genpass.pl.txt) v3.0 2005-08-26
: Generate random passwords of arbitrary length and complexity. v3 is
  a re-write to clean up the code and make it more modular. It also
  now changes interface modes based on script name (.cgi or .pl, still
  need to manually edit and add -T). New for 2.2 was dual
  interfaces--GenPass can run as a CGI script or from the command
  line. New for 2.1 was a Hex option, for generating WEP keys. Try the
  *[CGI/web interface](/cgi-bin/genpass.cgi)*\!

[GrepCount.pl](/public/source/GrepCount.pl.txt) v1.0 2003-03-21
: Count the frequency of a list of regular expressions in arbitrary
  input data so that a file for use with 'egrep -f' can have the most
  frequent expressions first so it runs faster.

[HTMLList.pl](/public/source/HTMLList.pl.txt) 1.0 2003-11-30
: Create a **simple** HTML list from text input.

[HTMLTable.pl](/public/source/HTMLTable.pl.txt) 1.1 2003-11-10
: Create a **simple** HTML table from (TAB delimited) text input.
  (Similar to csv2html.pl)

[ipa2int.pl](/public/source/ipa2int.pl.txt) 1.1 2004-01-30
: Translate an IP Address to a MySQL-style integer, or reverse. Useful
  for pre-precessing data (i.e. FW logs) before it is imported into
  MySQL.

[pivot.pl](/public/source/pivot.pl.txt) 1.0 2003-09-19
: Pivot cells (e.g. columns to rows) in a table

[subtotal.pl](/public/source/subtotal.pl.txt) v1.1 2003-06-26
: Subtotal arbitrary line items. Assumes that the number to subtotal
  is the first field and that the rest of the line is the keyfield
  (i.e. hash value).

[Merge](/public/source/merge.pl.txt) v2.7 2002-09-30
: A very UGLY and complicated but flexible generic program to merge
  two data files with a common, unique key.

[MergeL](/public/source/merge.pl.txt) v1.3a 2003-01-13
: A more simple and generic program to merge lines two data files with
  a common, unique key. This program is similar to the UNIX join
  command, but is intended more to process TAB delimited files cut
  from and pasted back into a spreadsheet. It creates a table or
  matrix of data, where each line is merged on a unique key (hence
  MergeL).

[WordFreq](/public/source/wordfreq.pl.txt) v1.0 2001-12-05
: Count word frequency in a text file. Basics from 8.3, page 280 of
 the _Perl Cookbook_, I just added stop words.

-----

## [GenSite](/public/source/GenSite.pl.txt)

GenSite is the simple script (relative to "real" Content Management
Systems (CMS) anyway) that created the HTML code for this site up until 2026.

~~My main constraint is that the ISP where most of the site is hosted does not
support SSI, CGI, or anything else that would facilitate a modern site.
I have various reasons for staying there, not the least of which is
inertia.~~  (That changed probably decades ago...)

So I needed a simple solution that would create a navigable
site without any those technologies. Also, after the last redesign
JavaScript fiasco, I wanted totally PURE HTML. Since the site is mostly
static, that was fine, except for being able to actually maintain it. So
I wrote this.

See the script code for lots more details.

[GenSite.pl](/public/source/GenSite.pl.txt) 1.12 2003-12-22
: Generate a static HTML-only web site from templates. (See also my
    GenSite wrapper [web](/public/source/web.txt).)

-----

## OLD

{{< snippet "old" >}}

Some Perl modules you might need (especially since I used them in some
of these scripts). Just extract the files (use WinZip) and copy `*.pm` to
`\perl\lib\Number`, `\perl\lib\time` or the correct path.

  - *[Time-modules](http://search.cpan.org/src/MUIR/)* by David Muir Sharnoff.
  - *[Number-Format](http://search.cpan.org/src/WRW/)*, by William R. Ward.

<!-- end list -->

  - [Fix-wls](/public/source/fix-wls.pl.txt) v1.0a 19-Mar-2000
    Converts those annoying WatchGuard \*.WLS files to Self-Extracting
    archives. This is obsolete with current versions of Live Security.
  - [LCaseHTML](/public/source/lcasehtml.pl.txt) v1.1 05-Apr-1996
    Converts HTML commands to lower case in HTML code, overwriting
    original file. (I got tired of inconsistent case on my HTML code.
    Talk about anal...)
  - [URL2HTML](/public/source/url2html.pl.txt) v1.1b 15-Nov-2000
    Converts URLs (in the form of URL{tab}description) to Bulleted HTML
    lists.
