Performance Computing: Perl Advisor: Figuring Phone-y WordsNov 14, 1999, 17:07 (0 Talkback[s])
(Other stories by Randal L. Schwartz)
"Every day, we seem barraged with phone numbers that "spell" things, like "please dial 1-ZZZ-HE-MUST-PAY to force your older brother to pay for the call!" That's because since nearly day one of dial phone service (back when it was really a dial), we've had these letters that go along with each of the digits."
"On one of the many mailing lists I follow, a question came up the other day: someone wanted to know if there were any large sets of words that all collided to the same number. I thought that'd be a perfect job for Perl, and in a short time, came up with a quick program to scan through the standard UNIXdictionary in /usr/dict/words to find the longest such collision list (or lists, if more than one). Since the program illustrates some basic data reduction techniques, I thought I'd pass it along to you as well."
"First, comes the most critical part. Given an arbitrary string, like "merlyn," what are the digits used to construct that? Well, we need to know that m is 6, and e is 3, and so on. Now, there are many slow ways to do this, but the fastest way is a tr operator..."