Perl: The Write-Only Language #

I've added extraction of email addresses (so that "User Foo <>" is split up, and also variants of the form " (User Foo)"). The code for this looks something like this:

if ($header =~ /^\s*([^<]*)<([^>]*)>\s*$/)
	$name = $1;
	$address = $2;
elsif ($header =~ /^\s*([^(]*)\(([^)]*)\)\s*$/)
	$address = $1;
	$name = $2;

Before I started to learn Perl, I said (to my dad, who uses (and likes it) a lot) that most Perl code it looks like someone held shift down and ran his fingers across the top and right side of the keyboard, and it looks like I wasn't far from the truth. But regular expressions (which are the statements to the right of the =~) are really cool, they let you do things which would take ages in C/C++ (actually the perl regexp engine is available as a C++ class too, but from what I heard the interface isn't that nice).

Other than that, I added the option to make the quoted part of a message appear in a different style (in my case, italics, and in a shade of gray). For the rest of the things that I have planned (threading, and sorting by the various columns) I have an idea of how I'm going to do it. Since they (especially sorting) simply require for the data to be arranged in a different way, it makes no sense to go back through the server to do this, instead, I can use JavaScript. So the plan is to have the Perl-based CGI backend to go generate a JavaScript script (which will mostly mean placing the header data within place-holders in the script) and then having the browser execute that script. When the user chooses a different sorting order, the JavaScript is executed again, with different parameters of course, but the server isn't involved at all. I'm also planning to use JavaScript for some of the other features, like having an automatic mail check option and for advancing through the messages (in the form of Next and Previous buttons in the toolbar at the top).

Post a Comment