Filtering for my Punchline

So as I mentioned in my first tweet, I recently wrote a Perl script that used Regular Expressions. I don’t know why I enjoy the pattern matching so much, perhaps it’s the ability to use a few lines of code to reprocess an entire text file. Anyways, I figured I should give a bit more background information. If nothing else, it’s a nice story.

A few friends and I have been playing Vindictus (an MMORPG from a Korean developer, like many others), but a reoccurring problem I’ve been encountering is that I’ll end up just a few AP, crafting mats, BP, etcetera short of whatever I’m trying to do. So, why not make it into a running gag? Vindictus lets you set a “motto” for your character that will display with your name, level, and guild for everyone at the start of each instance run. After finding a couple lists of one line jokes I tried to write a Perl script to filter it down to the “X short of a Y” style ones. The idea being that I’d just open up the file and pick one at random every couple of instances to provide a nice laugh for my friends.

Yeah… I ended up spending hours trying to debug the thing, writing it several different ways, testing the Regular Expression I was using with online tools, and generally scratching my head. The code was not wrong! So where could the prob-Oh yeah. When saving my list to a local text document it wanted to use different encoding to preserve characters. I thought nothing of it, saved it, and moved along. Going back and changing the encoding to standard ASCII fixed my problem, didn’t even find any special characters that I needed to worry about. Yet another lesson in checking one’s inputs.

~ by Anthony Strang on December 13, 2010.

Leave a comment