in reply to switch, transliteration ( tr/// ) of $_ issue

Hello,

I don't have a reply that directly relates to your code... but my advice is to just use a data structure. Why write procedural code when you don't have to?

my $foo = 'II';

my %table = (
  III     => 'high',
   II     => 'med',
    I     => 'low',
  default => 'drat',
);

my $bar = $table{$foo} or $table{default};

print "Foo: $foo Bar: $bar\n";

Hope this helps,

trwww

  • Comment on Re: switch, transliteration ( tr/// ) of $_ issue