I've come to the conclusion tonight while working on a VERY old PERL sendmail script that it's very difficult to shake the old scripts that I never thought I'd have to support even again. Those scripts which started off my career in web programming seem to pop up unexpectedly with issues or changes that need to be made.

Some of these scripts make me want to scream. I mean with all the experience that I've gained over the past few years has taught me to be a better coder, and I always tend to question my own programming habits when I get back to working on something from my past. What was I thinking? If I had the time to spare, I'd go back and rewrite them all, saving dozens of lines of code, no doubt.

Take for instance the old PIPE to sendmail routine:

open (MAIL, "|/usr/lib/sendmail $recipient") || die "Can't open sendmail\n";
print MAIL "From: Your best buddy
Subject: Nothing important\n\n
You are reading email.\n";
close (MAIL);

Now send this message, OR DIE!!! What kind of code was that, really? Oops, I can't send the message, so just stop the whole dang process here. No message to the user, nothing. Some great coder I am, eh? If I had taken the time to learn more about modules, I would have had much cleaner and more reliable code out there. Instead, I have a bunch of these functions all over the place. Lord help those who move their sites to Windows servers!

The lesson here? Make your code as modular as you can. Learn to write reusable functions. Learn from other peoples mistakes and maybe you won't be wondering why you "DID THAT".