I’m not exactly the model programmer, but I’m a big nut on readable code.

I’ve been doing a lot of PHP, but now I’m starting to get back into Perl. And I’m realizing that, in Perl, it’s very easy to write code that makes absolutely no sense to anyone except the most seasoned veterans. It does a lot of what I occasionally chastize myself for doing: taking bizarre shortcuts that shave a few seconds off of writing the code, have no impact on performance, but make your code fairly hard to interpret.

I was trying to figure out how readline() works, for example (I shouldn’t have to look that one up), and they gave this example code block:

    for (;;) {
        undef $!;
        unless (defined( $line = <> )) {
            die $! if $!;
            last; # reached EOF
        # ...

The very first line is odd: a for loop with no parameters. It’s easy enough to assume that it’s to do an infinite loop. The next line ensures that $! is undefined, $! being a variable pointing to errors. (Obviously. What else could $! mean?) The $line = <> is probably clear to anyone who knows Perl, though it’s certainly not intuitive as explicitly stating that it’s referring to STDIN. I find the unless() syntax to be nifty: it’s the same as if(!(…)), but a little clearer. Except I only find it intuitive if it’s expected that the evaluation will be true: unless a rare event happens… Here, it’s unless reading from STDIN is defined.

And even the die() bothers me: maybe there’s no sense in writing out an if($!) { die $! }, but I would have.

All around, I feel as if everything in Perl relies on very terse, bizarre naming schemes, and have always thought that a lot of Perl programmers take pride in writing the most obfuscated code imaginable. There are a lot of languages that I can “read” pretty well: I can sit down and look at your code and figure out what it does. But Perl isn’t one of them. Case in point: I’m scratching my head trying to make readline() read a line of data at a time. That’s what it’s supposed to do, but that’s not what it’s doing. Another time, a function returned an array full of references, a fact that was buried somewhat obscure in the documentation. Don’t get me wrong: it’s a very powerful language, and some brilliant people have done some amazing stuff with it. But it doesn’t have the same beginner-friendliness that other languages do. The same could be said, I suppose, for vi or Linux. But I have lots of reasons why I think Linux and vi are much better than the alternatives. I don’t have any reason to think that Perl is any better than its numerous alternatives. (PHP, Ruby, Python, bash…)


I woke up in the middle of the night, and glanced up at my clock. 1:33 AM. But wait, why is it light out? There’s no way I slept 15 hours and it’s 1:33PM? No no, my phone says it’s 6:30 in the morning.

I went back to bed, and woke up a few hours later, at 1:33 AM.

My clock radio crashed. None of the buttons did anything. I had to reboot it by pulling the plug, and now it’s back to normal. What’s the world coming to when a clock radio needs rebooting?

Just Sayin’

PRQ is the Swedish company that hosts sites like The Pirate Bay and some of their affiliated sites, like free image hosting and so forth. It seems that The Pirate Bay benefits from a mix of strong consumer protection laws (so that it’s harder to crack down on hosting a torrent tracker, which doesn’t directly host anything illegal), along with a hosting company run by a team of lawyers who might give Alan Shore and Denny Crane a run for their money.

Google Translate helps translate their site (except that it continues to translate “SEK,” the Swedish Kronor, into “USD,” which makes understanding pricing very confusing), which reveals that they offer colocation starting around $60/month, with a 300GB monthly transfer cap, and VPN tunnels with no bandwidth cap starting at about $12/month. (Plus VAT, which appears to be 25%).

I don’t advocate illegal activity, and neither do they. But just thought I’d point out an interesting company.


Why is it that, every now and then, I read a news article and start to wonder if the people we share this planet with are really human, or if they’re slightly less-evolved than apes? Who tears down the doors to Walmart and tramples an employee to death so that they can get a good deal on a new HDTV? Certainly not humans.


Out of all the talk of viruses, trojan horses, rootkits, spyware, adware, and so forth came the very helpful terms “malware” or “badware,” to encompass all of the harmful software out there. It might try to delete all your files, steal your credit card data, or just display advertisements and garbage all over the place.

But a pet peeve: if your program tries to install toolbars in my web browsers, and those options are checked by default, I consider your program to be badware. It’s not as bad as a virus, sure. But it’s trying to foist unwanted crap on my computer.

The problem is that all sorts of otherwise-good programs are guilty of this. Apple’s updater, used to keep iTunes current, is notorious for trying to get people to install Safari, by having it checked by the default. Last time I installed CCleaner and Defraggler, I think they tried something similar. And all of this stuff makes me lose respect for these companies. If I’m installing an update to Java, what does the Yahoo Toolbar have to do with anything? It’s been years, but I think Quicken gave me a bunch of icons for unwanted services, too.

I think most of these companies end up getting paid in some manner by getting people to install this crap. This is really shady. If you want me to install a relevant toolbar, you can give me the option, but it shouldn’t be on by default. But when I have to jump through hoops to not install something that’s completely unrelated to your product? I consider your software “badware,” and I lose a lot of respect for your company.


Like most posters and readers here, I’ve been using computers for a very long time. One thing that’s always baffled me is people’s obsessions with clearing out caches.

I’m sure that there are some programs that do caches wrong, and never purge anything, so that purging caches is sometimes beneficial. But I question how many people even know what a “cache” is. People seem to think of “cache” as synonymous with “cruft,” as if it’s garbage that builds up and needs to be manually scraped off of your computer every few weeks so it doesn’t come to a grinding halt.

In actuality, caches help keep your computer running fast, by, well, caching often-used data so that it’s faster to access next time. Your web browser’s cache? That’s so that, next time you load a page, it won’t waste its time downloading content that hasn’t changed. The Windows Prefetch cache? That’s so programs load faster. The thumbnails cache? That’s so that Windows doesn’t have to manually process every 10-megapixel image, in a folder of hundreds, every time you open it.

There are some good reasons to purge your caches, like if you’re dangerously low on disk space. As my previous post indicated, every now and then, something will screw up the concept of “caching” and never remove outdated things from the cache. This is a bug, though, not how most caches work. Most things use either time-based caches (where anything that’s been in the cache for more than, say, a week, will get purged automatically), or size-based caches (where, when the cache reaches, say, 500MB, it will start removing the least-recently-used items). Thus caches shouldn’t be something you need to worry about much.

Another reason to clear out your caches would be if you’re getting weird behavior. This can range from the simply, “Why is Youtube loading in Swedish?” (It somehow got the wrong location data for you, and that got cached, though it’s really a cookie issue.)

But for performance? Leave the caches alone! It just amazes me how many people empty their web browser’s cache every time they’re done using it, and then wonder why everything is slow. It’s because, in their misguided quest to optimize their computer’s performance, they just deleted all the files that were there to optimize its performance. Even more ridiculous is all of the advice about cleaning out the Windows Prefetch data for performance. These people clearly have no idea what the Prefetcher is, because deleting all the files is about the worst thing you can do for performance.

Of course, this doesn’t mean that programs like CCleaner aren’t valuable. There is a lot of cruft that Windows and its oft-used applications build up that isn’t needed. But that’s really an entirely separate issue from purge all of your caches, all of the time, because CCleaner’s strength isn’t in purging caches, it’s in finding totally useless cruft on your filesystem.

Losing Disk Space on Vista?

I went to run a defrag in Vista last night (via Defraggler), and noticed that the most-fragmented files were hundreds of files, each hundreds of megs, in C:/ProgramData/ Microsoft/ Windows/ WER/ ReportQueue. A bit of poking around revealed that they don’t serve much of a purpose.

Rather than emptying the folder by hand (which is probably safe from what I’ve seen), you can use the Disk Cleanup tool (included with Vista, type “Disk Cleanup” in the start menu’s textbox and it’ll come up) to do it. I reclaimed 7 GB of space, which is a lot when you’re talking about a tiny ~55GB partition for Vista. In researching this online, I found a few people talking about their ReportQueue folders growing to hundreds of gigs in size.

CCleaner hadn’t detected this folder, though I’m not running the latest version, and I certainly don’t mind it erring on the size of conservatism when finding system-created folders that it thinks I don’t need.


Nashua PD do a lot of patrols on their strip of Route 3, driving their trademark Chevy Impalas. Besides the fact that they just look like police cars, they’re seen driving them so often that I think most everyone who drives on Route 3 knows to slow down when they’re near an Impala.

In Boston, I was sitting on 93, not moving at all. A car went by in the breakdown lane. “What a jerk!,” I thought. A few seconds later, a Nissan pickup went by in the breakdown lane, driving even faster. “Now look what you started!,” I shouted to no one in particular.

Then some strobe lights on the back of the pickup came on, and I saw a guy wearing jeans and workboots hop out. “Is he a construction worker?! What the heck is going on?”

As I got a bit closer, I noticed that the guy in jeans and the baseball cap had a badge hanging from a chain around his neck (like you typically only see in movies?) and a gun on his hip.

That’s how you do it. You don’t drive an unmarked Crown Vic or a fleet of Impalas with a pigtail whip on the back. You drive a Nissan pickup and don’t dress like a cop. (But you also don’t do what some departments are apparently fond of, and try pulling people over with no real identification at all. Once I was past, I could see that he had ample blue lights on the front, in case the gun and badge weren’t convincing enough.)

I think it’s particular effective, too, because it communicates the message that there might be a cop watching even if you don’t see a black Crown Vic behind you.

Boston Politicians

I’ve been listening to various talk radio programs on my way into work, and most are based out of Boston, so there’s been a lot of discussion about the FBI stings that have been uncovering a lot of corruption.

One day it was about Boston’s Chuck Turner, and how he had announced that he was going to hold a rally after being accused by the FBI of taking a $1,000 bribe. The next day it was about how he held the conference, but, on the advice of his lawyers, didn’t actually talk about the merits of the charges at all. They had a few segments, where HE WAS SHOUTING, JUST A FEW WORDS, AT A TIME.

And last night on the way home? The most awesome announcement in politics, ever.

I have no idea of the merits of the charges against him, but have to say that this is perhaps the most hilarious outcome of corruption charges imaginable.

IMAP from Perl

I’m quickly finding it necessary to get back “into” scripting: I’d throw stuff together here and there, but it’s been a while since I wrote anything more than a dozen lines or so, and I haven’t done anything with Perl in far too long.

For a project I’m going to be doing, I just discovered something awesome: Perl’s Net::IMAP::Simple

This code doesn’t actually do much, but it’s still pretty neat how simple Perl makes it:

# Open the connection
$server = new Net::IMAP::Simple("$servername") or die("Couldn't open connection to server $servernamen");
print "Connected to $servername...n";

# Authenticate
$server->login("$user", "$pass") or die("Couldn't authenticate with server as $user : $passn");
print "Authenticated as $user...n";

# Get a message count (frivilous)
$message_count = $server->select($folder) or die("Selecting folder $folder failed.n");
print "Connected with $message_count messages...n";

# Print a list of all folders?
@folders = $server->mailboxes();
foreach $x (@folders) {
        print "$xn";

With a little looping magic, it should be easy enough to extract whatever’s needed from each message! (There are some more complex IMAP scripts, but, well, they’re not called IMAP::Simple…)