[Pdx-pm] sub calling logic
curtis_ovid_poe at yahoo.com
Mon Dec 22 18:24:29 CST 2003
--- "Roderick A. Anderson" <raanders at acm.org> wrote:
> Yeah. I almost, in a fit of madness, did this once. My current
> has far too many output subs. I'm trying to use the idea above to
> them to one generalized subroutine and pass in the differing types.
Well, if helps, here's a program that I use a lot at work to summarize
web tests that run nightly:
# a bunch of use module statements
# initialize variables
copy($mail_file, $mail_local) or die "Could not copy $mail_file to
my $folder = new Mail::Folder('mbox', $mail_local);
print message_summary($folder, $folder->message_list);
unlink $mail_local or die "Could not unlink $mail_local: $!";
You'll notice that, with the exception of tests on my file operations,
there's no logic here. There are only commands. By pushing my
iterations and conditionals as far down as I can, I reduce each logical
portion of the program to the least complicated structure that I can.
I find I write fewer bugs that way, but your mileage may vary.
Silence is Evil http://users.easystreet.com/ovid/philosophy/indexdecency.htm
Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
More information about the Pdx-pm-list