in reply to switch, transliteration ( tr/// ) of $_ issue
Aren't you "switching" on $foo ... but checking the value of $_? Shouldn't it be this? (untested)
switch ( $foo ) { case ( ($foo ~= tr/I/I/) == 1 ) { $bar = 'low' } case ( ($foo ~= tr/I/I/) == 2 ) { $bar = 'med' } case ( ($foo ~= tr/I/I/) == 3 ) { $bar = 'high' } else { $bar = "drat" } }
UPDATE: nope. That appears to be right. Yuck. I'm with kyle on this one -- don't use Switch. Use an if-else block or a dispatch table instead.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: switch, transliteration ( tr/// ) of $_ issue
by Bloodnok (Vicar) on Nov 18, 2008 at 16:31 UTC |