The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Sunday, March 13, 2005

No place like home

Clump clump clump clump clump—

Nothing—

Clump clump clump clump clump—

quite like—

Clump clump clump clump clump—

a three year old—

Clump clump clump clump clump—

girl in ruby shoes with—

Clump clump clump clump clump—

large heels walking around—

Clump clump clump clump clump—

upstairs.

Clump clump clump clump clump.

Sigh.


Too many emails

Email.

Or rather, an abundance of email.

Smirk called, saying that one of our servers was dying under a severe server load, and asked if I could write a script to clean out the sendmail queues.

So I spent some time writing some Perl code to do just that.

I don't like Perl. To me, it represents the worst of /bin/sh, awk, sed and grep (among other throat clearing noises that represent Unix commands). But for one off stuff like this, it was probably quicker than trying to do this purely under /bin/sh or even C.

In retrospect, I think I could have written it faster in C.

First off, I write my Perl using “strict”; it's enough that Perl will gladly accept simple typos (unless in “strict” mode). But that lead to problem number one: I couldn't figure out how to use Getopt::Std (Perl code to parse the command line) in “strict” mode. I had to spend some time figuring out that the correct incantation to use would be:

use Getopt::Std;
use strict;
  
use vars qw($opt_h $opt_b $opt_d $opt_t $opt_D);

getopts('h:b:d:t:D');

(in this code, -h is to scan the headers, -b to scan the body, -d to specify the queue directory and -t to specify where any email matching should be copied to, and -D to output debugging messages)

Okay, next problem: it's not finding anything. I grep through the headers, find something like “Subject: AdD Thr33 IncHes 2 ur MOrtgAge” then run the script:

./movequeue.pl -h 'Subject: .*[Mm][0Oo][Rr][Tt\?][Gg][Aa@][Gg][Ee3]' -D'

And nothing shows up.

Debug debug debug.

Turns out I'm a bit overzealous with using “my” (which is used to declare which variables I'm using in “strict” mode). Each instance of “my $variable” causes it create a whole new variable. So of course:

foreach my $entry (@queue)
{
  if (my $entry =~ /[dqx](.*)/)
  {
	# blah blah blah
  }
}

isn't going to work, since I effectively get two new variables by the name of $entry.

Okay, declare all the variables I use in one spot. That fixes that problem, and a whole slew of other problems related to scoped variables.

But at least the code is working.

Why yes, I'm still learning Perl.

And I still don't like it.

Obligatory Picture

[The future's so bright, I gotta wear shades]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.