Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Matts (1087)

Matts
  (email not shown publicly)

I work for MessageLabs [messagelabs.com] in Toronto, ON, Canada. I write spam filters, MTA software, high performance network software, string matching algorithms, and other cool stuff mostly in Perl and C.

Journal of Matts (1087)

Friday May 16, 2008
09:59 PM

I'd do it...

If I were asked to speak at google I'd ask for this too:

I simply ask Google to change a few lines of code, you know, couple of minor alterations, nothing truly significant. That way, he said, anytime anybody in the world Googles, “photography,” they get sent to my website.

From: http://www.joemcnally.com/blog/2008/05/16/google/

Nothing much. Just a few lines of code. No speaker's fee. :-)

Friday May 02, 2008
01:59 PM

Config file complication

Someone asked on IRC today what's a nice simple module to use for config files. Someone suggest YAML. Jeez, talk about not simple. And YAML is actually hard to write by hand. Someone else suggested XML with XML::Simple. Same thing - a large complex module and the config format isn't particularly user editable. No disrespect meant to those who suggested those things - I just think differently...

All you usually need is INI files. Here's a simple parser I often use:

sub parse_config {
    my ($self, $file) = @_;
    open(my $fh, $file) || die "open($file): $!";
    my @lines = <$fh>;
    close $fh;
    chomp(@lines);
    my $config = $self->{config} = {};
    my $section;
    for (@lines) {
        s/^\s*//;
        s/\s*$//;
        next unless /\S/;
        next if /^#/;
        if (/^ \[ (.*) \] $/x) {
            $section = $config->{uc$1} = {};
        }
        elsif (/^ (\w+) \s* = \s* (.*) $/x) {
            die "key=value pair outside of a section" unless $section;
            $section->{lc$1} = $2;
        }
        else {
            die "invalid line in $file: $_";
        }
    }
}

It's nice and simple, requires no external modules or CPAN downloads, and works pretty well for most situations where simple config files are needed.

Tuesday April 15, 2008
05:05 AM

Seed

For a test. Please ignore. mark@advancedambient.com.

Tuesday March 04, 2008
10:44 PM

Fun with IMAP

So I've been playing with IMAP lately, processing a folder of emails to process. It has been kind of interesting (to say the least).

Those of you who follow my CPAN uploads know I created Net::IMAP::Simple::NB, which is a subclass of Net::IMAP::Simple but using non-blocking I/O. The idea for that originally was to create a webmail system for AxKit2, but it was also fun learning how IMAP works.

There are some really interesting corner issues in IMAP that surprise me. For example an IMAP server is expected to be able to parse MIME messages, and be able to provide different components of the body as requested. This seems odd to me as frankly this should be a client task - surely this slows IMAP servers down? Also when you ask for the body structure it maps it in a very odd manner - though perhaps its useful for clients - there seems to be a lot of structure data there that isn't useful. There are some other odd choices too, like dates are provided as "DD-MON-YYYY" rather than the more ISO compliant "YYYY-MM-DD" format, and email addresses are provided pre-parsed, which means if your IMAP server gets it wrong you're screwed (though I guess that isn't too common).

On the other hand there are some nice things too, like IMAP provides most of its data in an S-expressions-like format, which is quite easy to parse in perl. The RFC is also not as horrible as I had once thought, so decoding various things is reasonably easy. On the other hand, it seems Net::IMAP::Simple is a bit too simplistic, in that it doesn't parse the output formats properly, and honestly doesn't have enough methods in it (I've added 8 methods just for my one simple app).

I'll have to consider contacting the author about patches. Though I'm unsure right now if I want to have too much to do with it in the long term.

Sunday March 02, 2008
03:24 PM

Time::Piece 0.13 released

Some of you may know that Time::Piece became part of perl 5.10. Anyone one of the things discovered was that I accidentally dropped a BSD copyright off one of the XS functions. This is now added back in. I also added an add_months() and add_years() set of functions, to make date arithmetic a bit easier.

This was interesting seeing what happens with the edge-case dates. It seems that when you do 31st March + 1 month you end up with 1st May. This mirrors what other date libraries appear to do. I documented the gotcha.

Enjoy.

Monday February 04, 2008
09:50 AM

Winter Creek

Image

        A small creek frozen over that I found on the drive home yesterday. The
        utter silence while taking this photograph was perfect, broken by the
        distant screech of an owl.

Original here

Monday January 21, 2008
09:05 AM

Brrrrrr

Image

        It's deathly cold out there, but I decided yesterday to wrap up warm
        and get my ass out there to do some photography. It was worth it for
        the results, but I sure couldn't hang around long.

Original here

Friday January 04, 2008
09:52 PM

On feeling out of touch

I haven't done much web development now for 7 years. I did a large-ish project at work using AxKit (probably one of the highest traffic mod_perl applications in existance, doing about 200 million transactions/day) about 4 or 5 years ago, but I don't really count that as it didn't expand my knowledge of web technology in any way.

I keep reading about new web "stuff" - Rails, Django, Seaside, etc. None of it really interests me all that much because frankly the core of the web doesn't appear to have changed a whole lot to me - you do a request and you serve a response. But maybe I'm missing something.

Email stuff of course still interests me because it's my day job. What's fascinating about my day job is that it's entirely built around people breaking the system and doing "weird" things, and me having to fix stuff. The most recent example was spammers sending QP encoded emails with high bit characters. That broke my QP decoding routines, but it also is a 100% spam indicator.

So is what is actually new and interesting that I should be looking into right now to keep my skills honed? When the web was dying (i.e. around 2000) it was XML, and learning and working with that served me well. What is interesting now?

07:28 PM

Terrorists win?

So tomorrow was supposed to be the start of the Dakar Rally. My brother-in-law Quin Evans was supposed to be co-driving in the race with his friend Ivar Tollefsen. A years preparation goes into the race.

Now the rally is cancelled because Al-Qaeda were supposedly targetting the rally. I hate that. Giving in to terrorists is just the worst thing. But losing a brother in law would have been worse.

12:49 PM

Rails has peaked

I found this blog post rather interesting. Though take it with a grain of salt obviously.