[ name withheld to protect the innocent.] [..] > From reading your response, below, I take it that you don't think very > highly of the SWITCH command? Can you elaborate just a little for me as > to why? You see, I've dabbled in other languages (most notably VB and > BASH shell scripting) and I've gotten quite used to having a CASE or > SWITCH type statement at my disposal, and, to be honest, I was surprised > that I didn't have it in Perl. I guess having "grown up" using it, I > didn't know why I shouldn't... [..]
I think almost everyone who comes to perl has that 'crisis of faith' moment when they review perldoc -q switch and wonder - ok, so why no switch/case statement, because, well I have always done it that way.... let me expose two ways of solving a common problem - cf - http://www.wetware.com/drieux/pbl/bloopers/hash_v_switch.txt given that I wrote both, and have done both, I rather doubt that anyone can blame me for, well, having issues with me..... Let us begin with assuming that we adopted the 'switch/case' class of assumption for 'code maintenance' related issues - such as not wanting to write all of those if/elsif/else cases all the way down. Likewise let us assume that one has not done the brainDeath trick of splattering switch/cases through the code, in lieu of 'racking and stacking' all of the thing related to 'one key' in the same place. I put that forward because it took us a while to finally understand the amount of work the coders 'had to do' to change 'verbs' in the language - because rather than the simpler switch($verb) { doMe : resolveDoMe(@arglist) ..... ..... default: HurlFurBall("there is no default for this"); } They had MULTIPLE places in their code where they would have to edit the text to insert a New Verb.... Rather than the really cheasy solution of updating their make file to include resolveDoNextVerb.c and hacking switchBox.c to look elsewhere for the function that deal with the DoNextVerb foo.... { we presume that you have already read: http://www.wetware.com/drieux/pbl/misc/HashSwitch.txt where you will note the complex software maintenance problem here of WRITE the Sub - add it to the list of actions, get on with your life. } { and for the OO pietist - yes, without argument, I agree absolutely one can totally make a bollocked mess of the multiple class inheritance problems that creep in and make classes brittle much faster and with more penache than old dog proceduralists can ever dream about. } At which point we are really down to the simpler set of problems about dealing with the 'native data types' of a given computer language, and how to work and play well with them.... if you look at http://www.wetware.com/drieux/CS/Proj/dump2disk/dumpToDisk.html you will find a 'stoopid awk and shell problem' - in which I do a similar type of switch/case in /bin/sh - that passes the RegEx to gawk - to grovel through $FSTAB - so yes, we have all done stuff that 'had to get done' - and the worst of the lot are the bits of Code Skank we used because a2p generated it for us, and we didn't stop to look at how STONED that really looked in perl..... the details of the argument by analogy: http://www.wetware.com/drieux/pbl/bloopers/slovenA2P.txt So technically no - I really can not defend my argument, perse, assuming of course that you are implementing 'switch/case' constructs in an appropriate manner using solid software development methods.... { especially if you have the time in your life to curl up with the perl internals for those intimate candle lit dinners with the current stable release of the software code itself, a little fondling and groping of the core components and data type primatives..... and of course your management happens to have staffed up to have enough coders on hand, as well as budgeted in the time to do an appropriate data analysis of the customer's need, that generates stable and extensible data models that simplify the process.... like as if that's gonna happen any time soon...} If on the other hand you grabbed for a switch/case statement because that is the way that we have always done things - you may wish to step back and think about whether 'doing it the same way we have always done it' will be any more effective in the long run for you - as it was the fifth time the rangers helo'd in on a suspect site in Mogadishu.... ciao drieux --- I'd think outside of the box, if Management ever had the cash to buy me a box to begin with.... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]