I misspelled “Pron” on purpose so that the spam bots won’t send me unwanted followers.
Disclaimer: This tutorial contains Alpha-level code (It is not ready for prime time). It comes with no warranty or assurance that it is suitable for any purpose. In fact, I urge you not to use it because — depending on how you use it — it can be overly aggressive in blocking people, in which case it may cause more harm than good. I take no responsibility, whatsoever, of the outcomes should you decide to use it.
The program is written in the Perl programming language: a difficult to read language that some have likened to line noise. You will have to be able to install Perl on your computer, unzip files into particular locations, edit files to add the words/phrases that you want blocked, and schedule a process to run on your computer. Restrictions on my time mean that, unfortunately, I can offer you no support.
Limitations: IMHO only Twitter has the access and the abiilty to do this type of filtering right. This program can only look at the last few Tweets in your stream so you might find it misses things if
1) You don’t have it scheduled to run frequently and
2) if your Twitter stream is more like a river.
The program also requires you to add some very specific block words/phrases and cannot go back in time. Pay very special attention to my explanation of how aggressive this program is. This program blocks people without asking you for confirmation. This is necessary for a program that runs at scheduled times when you are not present.
Other OS: These instructions are for Windows users. This program should work on other operating systems as well. Mac and Linux users already have Perl installed. You just need to unzip the program files to a location where you can get to them from the command line. You also need to know how to schedule processes in cron. These are details that I’ll leave to you and/or your techie friends.
Origins: This program is a quick-and-dirty hack that I put together in the span of a few hours in attempt to ease the pain of a particular Twitter user: my Reiki instructor @gassho. I think @gassho is right and Twitter should address this problem directly. Sign @gassho’s petition here if you think so too.
I personally believe that Twitter should develop a filter like the Askimet and other SPAM prevention plugins available for WordPress and give users the option to use it or not. This type of spam is difficult to combat programmatically; however, shared community action has been proven to be quite effective.
Okay, if you’re still with me, then read on…
Step 1: Install Perl

1. Go to http://www.activestate.com/activeperl/
2. Download and install ActivePerl
Step 2: Download the zip file containing the program and needed libraries.

1. Right-click on this link and save the zip file to your Desktop: http://dl.dropbox.com/u/121222/zen-twitter-tools.zip
2. Extract the contents of the zip file using your favorite Zip archive utility: right-clicking in Windows XP & Vista, 7-zip, Win Zip, etc.
Step 3: Copy the folder to the root level of your C: drive

1. Open “My Computer”
2. Click on the zen-twitter-tools folder with your left mouse button
3. Holding down the mouse button, drag the folder over to your C: drive
4. Drop the folder on the C: drive
Note: If you’re using Vista or Windows 7, you may receive a “permission denied” message and have to create this folder first.
Step 4: Add your Twitter user name and password to the configuration.xml file

1. Click on the zen-twitter-tools directory in Windows Explorer
2. Right-click on the credentials.xml file
3. Click on Open With
4. Click on Notepad
5. Change the username and password to your own Twitter account credentials and select File | Save
Step 5: Taking Great Care and with Much Thought, Add Words / Phrases to Block

1. Right-click on block_in_names.txt and open it in notepad
2. Right-click on block_in_tweets.txt and open it in notepad
3. Add words to block in block_in_names.txt
4. Add words and phrases to block in block_in_tweets.txt
Take great care and put much thought into this. The matching algorithm is very aggressive. In technical terms it uses case-insensitive, greedy matching. Take responsibilty for your actions: you are defining rules for a robot program to perform actions for you in your absence.
This means that if you say that you want to block Twitter names containing the word “an” it will also block “Anthony” and “Brian” and all your other friends with the consecutive letters “AN” or “An” or “aN” or “an” in their name. Britney will not block Br.it.ney or B.r.i.t.n.ey or B_r_t_n_y. If you block the word follow, you’ll block all your #Follow Friday friends.
This also means that if you want to block tweets spammers tweeting the phrase “100 followers in a day” that you will also block your friend who DM’s you saying “Don’t you hate those spam DM’s promising 100 followers in a day?”
It’s very difficult to match all possible permutations. In general, you want your block words and phrases to be as long and specific as possible to avoid blocking people who have done no wrong.
At this point, I hope you have some insight into 1) some of the difficulty of writing programs like this, 2) why Twitter needs to get involved, and 3) why a community-based system like Askimet could be more effective, 4) why you’ll want to monitor the agressive-block.log file to find people who have been blocked my mistake and unblock them.*
* This is that “more harm than good” stuff that I mentioned at the beginning.
Step 6: Check your Credentials

This program runs from the CMD tool, also known as the Command Prompt or DOS Prompt.
1. Run CMD.exe: Search for CMD or Start | Run | CMD
2. Change directories to your zen-twitter-tools directory: cd \zen* or cd \zen-twitter-tools
3. Run the command: perl account_verify_credentials.pl
Example: C:\zen-twitter-tools>perl account_verify_credentials.pl
You entered your username and password incorrectly if you get this: Login failed. Verify credentials.xml
Edit the credentials.xml file and correct the problem.
You’re good to go if you get this: Successfully logged in as [Your Name]
Step 7: Block the S.O.B.s and Most Likely Some of your Friends

1. Run the command: perl aggressive-block.pl
There is no output in the above screenshot, indicating that no one was blocked (there were no matches in the last ten tweets in your stream or in the last ten direct messages to you).
Here’s some fake examples on how it’ll look when the program blocks someone:
C:\zen-twitter-tools>perl aggressive-block.pl
You are now blocking @B.r.i.t.n.e.y: Spam Bot Britney
Type: Mention
Blocked @B.r.i.t.n.e.y
for having “B.r.i.t.n.e.y” in screen_name:
@B.r.i.t.n.e.y
You are now blocking @Br.it.ney: Fake Britney
Type: Direct Message
Blocked @Br.it.ney
for saying “Join my Mafia Family!” in this tweet
@YourGoToGuy Join my Mafia Family! http://fakeurl.com
Step 8: Unblock your Friends

If you specified text that matched your friends, you’ll need to manually unblock therm, either by 1) searching for their name in Twitter or by 2) running the block_destroy.pl program from the command line.
Note: The program logs all it’s blocks in the aggressive_block.log file, so review it often. You can also see the people you’ve blocked using the command: perl block_blocking.pl
This is looking more and more like a bad idea. Twitter Give Us The Tools to Save Ourselves From Pron Spam! Clone Askimet for Twitter!
Step 9: Schedule the Program to Run Unattended

Ah, this is hard part because it is different for every operating system, even better different Window Versions. So you’ll to google this for instructions for your particular operating system. On older versions of Windows, the scheduling program is called “at” as in run this program at this time. On Linux and Macs, the command is cron.
On newer versions of Windows, go into the Control Panel | Administrative Tools | Task Scheduler.
You want to schedule a job to run this command several times daily:
c:\perl\bin\perl.exe c:\zen-twitter-tools\aggressive_block.pl
You’ll have to experiment with the frequency, but the program only checks the last 10 tweets or DMs in your stream, so you’ll probably need to run it every 5-15 minutes. You can’t run it too frequently or you’ll run out of Twitter API tokens.
Step 10: Petition Twitter to Put their New Cash Injection to the Best Possible Use

Only after creating this program, did I realize that ultimately this program is just a band-aid which will most likely cause more harm than good. I feel that Twitter should aggressive tackle this problem. Sign @gassho’s petition if you agree.
Why is this a problem? Read this.