Death to letters

brian_d_foy on 2002-09-12T01:16:04

Douglas Wilson sent me a ternary operator alternative to my do {} happiness. I like the parallel structure and the visual appeal.

my ($var1, $var2) =    
   ($sw == 5) ? (1,2)  
  :($sw == 4) ? (3,4)  
  :($sw == 3) ? (5,6)  
  :($sw == 2) ? (6,7)  
  :             (8,9);


Since he eliminated the if-elsif typing, I wondered if I could eliminate the rest of the letters. If I allow myself to use special variables, I cannot use my() (since special variables are always package variables) and any letters in the variable names.

($\, $/) =
   ($_ == 5) ? (1,2)
  :($_ == 4) ? (3,4)  
  :($_ == 3) ? (5,6)  
  :($_ == 2) ? (6,7)  
  :            (8,9);


And then if I can get rid of extra whitespace...

No, I am not going to do that. I have not entered an Obfuscated Perl Contest yet and I do not want to start. Down that path lies madness.

This reminds me of an answer with no semicolons.