Stupid Perl Trick: Mnemonic Phone Numbers
- Prerequisites
- The PhoneToWord Module
- How to Use It
- Reader Exercise
- Listing
About a year ago, I moved to a new state. Of course, with moving there are dozens of things to do. One of these things, which I really dislike, is remembering new telephone numbers. As I was getting settled, I had (at a minimum) these phone numbers that I needed: work phone, home phone, friends' numbers, cell numbers, coworker numbers, etc. That was a lot of numbers I needed to be able to recall.
I figured I had a few options. I could purchase a PDA, but from experience I tend to not use them. I could memorize all of them, but that would take too much brain power at the time (remember, I just moved!). I could use the old "paper in the wallet" technique, but I would likely lose the paper (again, from experience). Or, I could make words out of as many phone numbers as I could to easily remember them.
I liked the last option best. Now, this created two new options on how to do this. I could either write a matrix of the numbers and try to create words by hand, or have Perl do it for me. As you may expect, I chose the latter of the two. This article will explain the module which I used (and still use) to help create words out of phone numbers.
A few things about this. Not all phone numbers are translatable into words. And this module is meant to work with U.S.-centric phone numbers, and doesn't take into account area codes (it's easy enough to add support for area codes; I just happened to not need that feature).
Prerequisites
This module uses three important pieces. One is the <span style="background-color: #00FFFF">ispell</span> program. The ispell program has many cool features, and the one we will be concerned with is its capability to see if a word is, well, a word. It does this by using a dictionary file, which brings us to the second important piece. The ispell program comes with its own dictionary, but it can also use other dictionaries (such as /usr/dict/words). You will want to read the ispell manual page to acquaint yourself with how to use various dictionaries. But, if you have ispell installed, you should have one and be ready to roll.
The third important piece is the Text::Ispell module, available on the CPAN. This module provides an interface to the ispell program. After everything is installed, you are ready to start.