If programming is an art, then these would be my everyday sketches and doodles.
primes.perl. This is a very simple two-dimensional projection of a three-dimensional prime number space. It's so simple, it's in text. The X axis represents a particular base. Y is the place in the base. Z is the described digit's value. If you want vt100/ANSI color, turn on the ANSI_COLOR constant.
foreachmap.perl. This is a benchmark for foreach vs. map in void context. I'd been assuming that map would be faster because it's less bytecode work, but it turned out to be about twice as slow.
csv.perl. A small demo of comma-separated values parsing, with embedded newlines in some fields. This was just a doodle; the CSV module on the CPAN is probably a better choice for serious data parsing.
gods.perl. Are you having trouble finding God? What about Goddess, gosh, goodness, gods, or ghod? Perhaps this regexp can help.
hexify.perl. Hexification is my word for converting characters to %## form for URIs. A while ago, I heard that using the /ge regular expression flags for this leaked memory, so I hacked out a way to avoid eval. This program benchmarks four hexification variants; it turns out the original way is by far the fastest.
inline.perl. Early versions of Perl didn't inline prototyped constants while profiling code. This program tested that. Note: you need to run dprofpp to see the results.
lop.perl. Every now and then someone asks for a function to lop the first character off a string. You know, like chop() but for the other end. I even asked Larry Wall about this, once upon a time in e-mail. lop.perl is a demo for a "worst-case" lop() function.
infix.perl. I don't recall exactly what this was for. I think Kevin Lenzo proposed a puzzle to convert infix operators into function calls. This program contains a regexp that takes "a b c d e" type strings and turns them into "b(a,c) c(b,d) d(c,e)". I think the idea was to evaluate the right side as function calls.
phones.perl. This is a decent attempt at recognizing valid telephone numbers from a single regexp.
charclass.perl. Quickly test a string to see if it consists only of certain characters.
sqrt.perl. Calculate square roots, the hard way.
taint.perl. A lot of people want to make tainted data safe. This, on the other hand, is for the folks who want to taint data that perl considers safe.
newsrc.perl. I needed to maintain .newsrc style files a while ago, back before I'd heard of the CPAN module to do so. This is my interpretation of the problem, using largish map() statements to do most of the work.
uniqchar.perl. A benchmark for different ways to count the unique characters in a string.
viruscheck.perl.gz. A brief exercise in self-verifying programs. This simple program prints the reverse of whatever is after __END__. It refuses to run if it's modified. Undoing the virus protection is trivial, so it's probably not a good way to prevent people from altering your code. Gzipped to avoid network lossage.
lzw.perl. LZW compression in Perl. Even if it was useful, you still wouldn't be allowed to use it without a license because it's patented. Thank you, the United States Patent and Trademark Office and the UNiSYS Corporation ("We eat, sleep and drink this stuff.").
Stuff on this page may or may not be Copyright 2000 by Rocco Caputo. All rights may or may not be reserved. If you're not sure, it's polite to ask.
$Id: perl.html,v 1.1 2000/08/26 22:00:21 rcaputo Exp $