Perl Scripts  

Here are a few hacks that have little in common aside from having been written in perl. Perl rules! A small stand-alone library defining just the get and getprint routines from LWP::Simple. So you don'thave to install 1.5 megs of stuff just to write a one-liner web client.

Here are some examples showing how to use the SimpleGet library.

MIRA: A text-only web browser with some powerful features. I wrote this myself to satisfy my need to search my own browser cache. While I was at it, I decided that all text should be cached permanently. MIRA was the result.

Hypercalc: An unusual calculator program. It represents numbers in a special way allowing the calculation of quantities like 128481024 or 888888. I used it to compute many of the examples on my numbers and large numbers page pages. See these pages:

Hypercalc : A full description of all versions, with a comparison of features, etc.

HyperCalc JavaScript by Kenny TM~ Chan: try Hypercalc right now, in your browser. Also, download the HyperCalc JavaScript manual (PDF).

My Perl version of Hypercalc is for Mac, Linux and Cygwin users who want full functionality, including extended precision up to 295 digits, and a BASIC interpreter for full programmability.

The nearest-color-name script uses data from the excellent xkcd colour names survey to give you candidate names for a colour, in a successive-refinement way. For example, consider the colour #1781b7:

bash$ nearest-color-name 1781b7 RGB values: (23, 129, 183) ... matches "green" (#15b01a) to within 66.55 (pop 522538) ... matches "blue" (#0343df) to within 64.28 (pop 502870) ... matches "teal" (#029386) to within 26.44 (pop 90575) ... matches "blue green" (#137e6d) to within 22.53 (pop 7548) ... matches "cerulean" (#0485d1) to within 14.38 (pop 5018) ... matches "water blue" (#0e87cc) to within 10.24 (pop 268) ... matches "nice blue" (#107ab0) to within 8.43 (pop 203) The closest match to (23, 129, 183) is "nice blue" (#107ab0)

it tells us that "green" got 522538 votes, and matches #1781b7 at a distance of 66.55, but the rarer name "cerulean" (with only 5018 votes) is a lot closer with a distance of 14.38, and so on. You pick the colour name that gives you the best tradeoff between accuracy of the colour-match vs. obscurity of the name.

The distance measurement is by Pythagorean distance within the RGB colour space, but is green is considered more significant than red, and red more than blue:

red2 = (0.6×(red1-red2))2
green2 = (green1-green2)2
blue2 = (0.3×(blue1-blue2))2
distance = √red2+green2+blue2

A Turing machine simulator. It has a line-oriented interface and runs in any console window (like xterm or kvt). Some sample output is seen on my pages describing the Marxen-Buntrock 'q' and the final Google Turing puzzle. It uses colour to show the current head position and state. It implements level-1 optimization (compression of runs and quickly skipping over sequential identical transitions across a run) using regular expressions. I was able to run 100 million steps of the 6-state busy beaver in just a few minutes.

This script runs once a day and updates my Programming Languages Sucks-Rules Chart.

My Apple II file extraction script reads a DOS 3.3 disk image (a text file of hexadecimal-encoded disk bytes), locates individual files and lists their contents. In order to do this it needs to know the 6+2 nybble conversion, sector interleaving, how to locate D5-AA-96 at the beginning of each sector, and token tables for both types of BASIC.

Perl: TMTOWTDI (There's More Than One Way To Do It) !

Robert Munafo's home pages on HostMDS   © 1996-2017 Robert P. Munafo.
aboutcontact    mrob    mrob27    @mrob_27    mrob27
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. Details here.

This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2017 Feb 02. s.11