Regarding your macro: "Ichiban, Taguchi-san!"  Now, if I knew what the 
editor was... I suspect it's a Japanese product, huh? (Guess the name gave 
it away.)

If you go back to your Camel book (p.105 in my copy), you'll see that the 
authors sort of deprecate the if-elsif-elsif-elsif-else structure. I've 
had good success using a for statement (actually a single-pass loop) to 
implement a switch structure, like this:

# ----------------------   code -----------------------
# assign value to $foo here, then...

for ($foo) {
   /^abc/ && do {
      $var = 'abc';
      last;    # required; prevents "fall-through"
   };
   /^def/ && do {
      $var = 'def';
      last;
   };
   /^ghi/ && do {
      $var = 'ghi';
      last;
   };
   # "default" handler goes here--the "else"
   $var = 'oops!'
} # end of for structure
# ----------------------   code -----------------------

This structure is outlined right below the elsif-elsif-elsif thing. It's a 
lot faster than all those elsifs strung together, also, a lot more 
elegant.  To speed things up even more, arrange the possibilities from 
most-likely to least-likely, if such an order exists.

Best wishes,

Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150

"On two occasions I have been asked [by members of Parliament], 'Pray, Mr. 
Babbage, if you put into the machine wrong figures, will the right answers 
come out?' I am not able rightly to apprehend the kind of confusion of 
ideas that could provoke such a question." -- Charles Babbage
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to