I'm a Pathetic Perl Hacker....

Monty J. Harder dmonster at juno.com
Thu Sep 21 03:32:36 CDT 2000


I obviously haven't been doing this crap nearly long enough.  Slashdot's
"Col. Klink" <wklink at yahoo.com> posted
<http://slashdot.org/article.pl?sid=00/09/20/141237&mode=thread> this
quite workable script, that beats the hell outta my amateurish bar-q:

#! /usr/bin/perl -n
printf "%s %s %sn",
map {
tr/a-zA-Z0-9+-/ -_/;
$_ = unpack 'u', chr(32 + length()*3/4) . $_;
s/0+$//;
$_ ^= "C" x length;
} /.([^.]+)/g;

Yep.  7 lines of code, and it works.  I program in Perl 4 out of
longstanding habit (I started with a DOS port) and didn't think of using
the map thang, plus I didn't quite grok how uuencoding worked (the unpack
'u' bit there.  This isn't just T-shirtable, as Hal originally wanted...
reformatted just a bit

#! /usr/bin/perl -n
printf "%s %s %sn",
map { tr/a-zA-Z0-9+-/ -_/;
$_ = unpack 'u',
chr(32 + length()*3/4) . $_;
s/0+$//;
$_ ^= "C" x length;
} /.([^.]+)/g;

this damn thing will fit on a standard-issue (1" x 2 5/8", 30
labels/sheet) address label (with room to spare), small enough to go on
the underside of the 'cat itself!  As this message wings itself to the
list, I'm printing some for "distribution".




More information about the Kclug mailing list