Here's the complete text of the entry you were just reading. To return to the whole blog, click thebutton at left.
I've always been a fan of scripting systems (except MS Office Macros ;-), so it seemed only fitting to learn a little Perl after moving to a *nix OS.... Big Mistake.
First, I didn't move to a new OS -- still too many clients on the old OS for me to risk putting something new on my main drives. Unfortunately, I was already hooked on learning Perl. So now to test my coding I have to run everything remotely (over a landline, f'r' Crissakes), which is about 1 step better than using punchcards.
Second, there's no such thing as "a little Perl" -- it's all or nothing. Larry Wall can talk about "natural language" all he wants, but there ain't nuthin' natural about Perl...unless maybe you're conversant with the code revealed by the Human Genome Project.
Third, Perl "textbooks" are just as dense and exception-filled as the language itself; something happens to the brains of people who code Perl that seems to destroy their ability to speak slowly and clearly. (Pay your $50 for Programming Perl and then try to find an actual definition of the ".=" operator, for instance.)
But, I wanted to do some Perl. I usually learn a language by getting a nice chunk of existing code and a syntax guide, then spending a couple of days curled up in the code. When a certain comfort level is reached, I start compiling my own snippets, building my skills until I can produce something worthwhile. Since my compiler was going to wind up being my domain host, and since I wanted to focus on file and text handling initially, the idea of running a blog seemed just about perfect -- learn from the blog code, modify the blog code, and see the results in ...the bog ;-)
Blosxom is a simple-yet-powerful blogging tool whose entire code fits in under 10 pages, runs from a single file, needs no exotic modules, and has healthy support. What's not to like?
Right away, there was something I wanted to change: like any real blog, Blosxom wants to load files by mod date, and preface each entry with that mod date. Fair enough; that's what constitutes a journal. But I don't necessarily want a journal; I just want a means to publish entries in a certain order, without automatic labelling (prefacing entries with mod dates). Shouldn't be too hard -- just add a variable to the "story" template to allow me to supply my own date for the entry; stop Blosxom from writing the mod date; and change the way Blosxom sorts files from mod date to alphabetical.
I expected the last item to be the hardest, and it turned out being the easiest... because I cheated ;-) I couldn't even begin to comprehend the default sort routine syntax, and there was no way I was going to write a replacement. Then I found a Blosxom "plugin" called "sort_by_name" (by Jacob Kaplan-Moss) that did exactly what I wanted. Even better, the code gave me several insights into Perl which made the "lesser" tasks (changing input and output strings) seem like they'd be easier.
LOL! Normally I use the word "hacking" in its best sense: lusty programming. Hackers work from com/passion -- some code is so beautiful you swoon over it; other code is tart and teasing and you can't stop it from leading you on; there is wounded code, a tender flower that just needs gentle care to blossom; there is shy code, seductive code, joyous code, cold code. At some point, the hacker falls in love (or love/hate) with the code, and lets passion have its day.
This may mean eye-popping intercourse with the code, or a hearfelt sharing, or a little propping up, or even some plain old discipline... but the central feature is that the hacker feels for the code; there is no one happier than a hacker who has just helped some code run better.
In the case of changing Blosxom, however, I have to use hacking in the sense of machetes and chainsaw massacres -- since I couldn't read the code all that well, I never saw its personality...I never had a glimpse of its soul. There was nothing to ignite passion; merely a journey to complete.
But, despite not being able to have a relationship with the code, at least I got it to where I like it ;-) Here's what it takes to: suppress Blosxom's automatic mod date; to sort files by name, not mod date; and to supply your own mode date within the body of the entry
- use the "sort_by_name" plugin
- comment out this line:
$curdate ne $date and $curdate = $date and $output .= $date;
- add a variable and formatting to the "story" template for supplying an arbitrary date; I added:
- change this line:
use vars qw/ $title $body $raw /;
use vars qw/ $dato $title $body $raw /;
- preceed this line:
chomp($title = <$fh>);
chomp($dato = <$fh>);