In recent post I discussed the creation of a stopwords database. The next step was to create a more reusable perl module to access that database. This isn't terribly complex: essentially we just want to know if a particular word is in the database or not. We are, however, going to use an object oriented interface.
the archive
A Stopwords Module
Markup Perl
I gave myself a challenge when I started this blog: 100% of the software used to run it would be written in Perl. That seemed fairly obvious given the title, but I immediately wanted something more suited to formatting HTML. Yes, there are more than enough Perl HTML-template tools available for such a job, but I'm picky, and I didn't want to have to learn some invented mini-language to format text, when I already knew the best language ever invented for formatting text. What I came up with has worked very well during it's usage here, and now you can try it yourself. My Markup::Perl module is now available on the CPAN.
Putting the "pl" in Apple
Spotted: When doing a search at http://developer.apple.com/ today, I felt the Perl.

In fact, Apple's support of open-source scripting languages is about as good as it gets.
Profile It
After a discussion on the local perl monger's list, and a lesson from Brian McCauley, I wanted to summarize Perl scoping with some examples.
Saying Hello to UTF-8
I'll be explaining how the On Perl search engine works in the next several posts but first a few preliminary items need to be addressed. The database I'm using is SQLite, and if you haven't heard of it yet, trust me, you soon will.
BlogML: Take Your Blog With You
Before long every line of code that is used to run the On Perl blog will be publicly available here, but this is the first step in that direction: the data back-end. This site is actually more than a blog--to me anyway--it is also a chance to experiment, so in every reasonable way I've tried to create better and newer ways of doing things. I've made some decisions I soon regretted, and then, a little wiser, made improvements. When considering how I would handle the back-end I was somewhere between the almost obvious MySQL choice, and the seemingly more elegant, sleeker file-based choice of Bloxsom.
A CPAN of My Own
If you're sharing a server, the first time you use CPAN you may find that it's already configured for the root account, in which case you'll get a load of errors about incorrect permissions to install anything. You can either try and get the root password, or (more likely) set up your own CPAN install. It's straightforward, if just a bit tedius.
mkdir -p ~/.cpan/CPAN cp /usr/lib/perl5/5.8.5/CPAN/Config.pm ~/.cpan/CPAN/MyConfig.pm perl -p -i -e 's!/root/!/home/michael/!g' ~/.cpan/CPAN/MyConfig.pm perl -MCPAN -eshell cpan> o conf makepl_arg "LIB=/home/michael/perl INSTALLMAN1DIR=/home/michael/perl/man1 INSTALLMAN3DIR=/home/michael/perl/man3" cpan> o conf commit cpan> install Some::Thing
A Game of Cards
It's summer, time to relax and have a little fun. So hows about a little game of cards? Or maybe I should have titled this: "Fun With Arrays." I actually just wanted an excuse to demonstrate a few useful techniques for working with arrays in Perl, but why not an array of playing cards?
Using GD and CAPTCHA
Now that I've got the GD module installed and working, it's time to give it something useful to do. In this post I'll describe how to generate and verify a CAPTCHA. Sadly, for the rest of us, spammers have taken to abusing free services available on the web via HTML forms. CAPTCHA is an attempt to limit form users to the human variety, in this case by asking the them to type in the letters displayed in an image.
Getting Started With Image Manipulation
I've had a couple jobs recently that required scripts to automatically manipulate images. I wrote one in PHP, using ImageMagick, and the other was in Perl, also using Image::Magick. I decided I wanted to do some of this sort of stuff on my Mac OS X iBook, but for various reasons wanted to give the GD module a try instead. I set aside an entire afternoon of free time, warned the family to stay clear, and prepared for the coming hours of thrashing in installation hell. Surprisingly, before I could even finish brewing the first cup of coffee, I was done.
Remote Differences
Want to see if the copy of that CGI script on your hard-drive is up-to-date with the one on the web server? Or maybe you suspect they're different in some small way, but can't tell by looking. Try something like this on the command-line...
ssh user@onperl.org 'cat www/cgi-bin/script.pl' | diff - script.pl
Module Won't Install? Check the Date
While testing a recently released module I came across a mysterious and generally useless error message from the CPAN installer. Well, technically it came from the makeutility, but the CPAN installer was the one supposedly in charge.
TextMate: Is it Time to Switch?
If, like me, you write code on a Mac, you have a history of working with BBEdit. I'm somehow embarrassed to admit my personal history of working with BBEdit goes back almost a decade. Hey, what can I say? I like things that are simple and work. I've tried other editors, but none hit the same sweet-spot of plain old get-it-done-edness. Then I heard about TextMate.
Matching Markup
I recently needed a way to translate simple markup into (uhm, another markup) HTML. The simple markup could be anything, but had to provide a way to format text entries. I figured POD was good enough.
A Few Comments on Comments
The point of a comment is to do nothing, so what good are they? Well, you might be surprised. Firstly they are an invaluable form of documentation. If you're trying to work through a complicated process start with comments.
Automated Unit Testing for JavaScript
Speak of "testing JavaScript" and most developers will conjure up images of editing an HTML file and then hitting reload on their web browser. That's probably not going to change, at least not as long as web browser support for JavaScript is so unpredictable. But if you have files of JavaScript you find yourself using more than once, you need unit tests.
A Perl 6 Example
We're through the looking glass now, folks. Perl 6 is still bleeding-edge alpha-ware but it will run, mostly, on the "pugs" interpretter. Well, at least enough to get a feel for the new syntax. It feels weird.
Module Finder
If you're working on a system that has multiple versions of perl installed with perhaps multiple users and a few different library locations, you might be confused about where to look when you get a problem related to a module. Where is the code for that module actually located? Got more than one of those modules installed in different places, which one is being used? Which version?
Pugs And Parrot on Mac OS X Just Got A Lot Easier
I've been toying with the idea of installing Perl6 on my Mac, maybe playing around with it a little. Unfortunately that's not a trivial task, but today it just got a lot easier. Perl6 isn't done yet. But there is a reference implementation built in Haskell. So you'll need to start by downloading and installing ghc. Then you're in luck, because David Romano has just released Mac installers for the other two parts you'll need: Pugs and Parrot. At least on my 10.4 system, this worked like a charm. Then you can start your next perl script with #!/usr/bin/pugsand follow along with the examples of Perl6 you'll start seeing here and, more and more, all over.
Seven Questions For Dag Ågren
Dag Ågren, also known affectionately as "WAHa.06x36", is the author of PerlHP.pm, a module that allows you to write Perl that looks like PHP, or as he puts it: "is it the other way around?"
Walking Recursively
Here's a quick recipe to scan a directory recursively (aka "walking") for all files that meet a given criteria--in this case I'm searching for perl scripts. In fact, because this is Perl, I'll give you three ways to do it!
Training Wheels
Randal Schwartz said it was like "training wheels without the bike" -- so why would anyone want to turn Perl into PHP? Dag Ågren explains it as a "travesty", a "joke" and something to "make Baby Jesus cry." We know it as PerlHP, and it comes pretty close to putting training wheels on the carbon-alloy LeMond racing bike of Perl. But is that a good thing?
Perl or Line Noise?
Think you can look at a Perl script tell the difference between code that will compile and strings of characters that might been generated by your cat walking across the keyboard while you were away getting another cup of coffee? Are you sure? Really?
Perl For Terrorists (And Others)
I'm not a terrorist. However I assume I do have certain things in common with terrorists. Mainly I'm not an idiot, and while terrorists behave in ways that can only be described as "murderously psychopathic", I don't think it's useful to assume that terrorists are in fact stupid if we are to have any hope of stopping them.
In this premier post we take a look at how CPAN can be used by terrorists and others to communicate incognito. Also we prove the American Government is wasting your money.
