[Pdx-pm] sub calling logic

Roderick A. Anderson raanders at acm.org
Tue Dec 16 14:11:24 CST 2003


This may fly in the face of good design so you should realize I am not a
'trained' programmer.  Some classes but lots of head pounding, beer,
swearing, and aspirin (along with LOTS of reading) is how I've learned.

I am working on a (#$%^&) CGI program that is getting out of hand quickly.  
Mostly because I have to deal with a 'less-than-well-documented' XML
interface on the back side and changing specifications.  So as this thing
growns like a fungus in manure I'm trying to ride herd on the code
proliferation.
   A rather cute trick occured to me as I again realized I had missed a
test and the script blow chunks ... again.  How about placing the
subroutine call anywhere I think it might fit and have it decide if it
needs to do anything.
   So instead of 

	if (something) {
	   doit();
	}
	# something is a grep for a key in a hash.

   I can

	doit();

sub doit {

	if (something) {
	      ...
	} else {
	      return;
	}
}

Nothing intensive happening in the sub and no recursion involved.


Thanks for any input,
Rod
-- 
    "Open Source Software - You usually get more than you pay for..."
     "Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL"





More information about the Pdx-pm-list mailing list