Work wrote: <snip>
if($userinput eq 'y') ## yucky { ... }
Uh, why?
If all you care about is the case 'y' then this is a much better and faster way to determine the truth or falsehood of the statement. It's also, IMO, the clearest of all.
If you really wanted to handle a couple of differenct options, then how about:
my %is_ok = ('y' => 1, 'ok' => 1, 'Y' => 1, 'OK' => 1, 'Ok' => 1);
if ($is_ok{$userinput}) { ... }
or
if ($is_ok{lc($userinput)}) { ... }
if($userinput =~ /^\s*y|(ok)/i) # nice { ... }
Heh, heh, *this* is nice?
I assume that this was supposed to be: =~ m/\s*(?:y|(ok))/i
But this is hardly easier than 'eq'.
jon
-- jon reades fulcrum analytics t: 0870.366.9338 m: 0797.698.7392 f: 0870.888.8880
lower ground floor 2 sheraton street london w1f 8bh