I have this Perl code:
@str = qw(a1 a2 a3);
my @array;
$s1 = 'a1';
$s2 = 'a2';
$s3 = 'a3';
Now given s1, s2, s3 get references to $array[0], $array[1], $array[2] respectively. A switch case is possible. but how to get it in one or two statements.
What you really want is a hash, not an array.
Now, if you still want to use an array for the index names and a different array for its values, well, it’s up to you, but you are using the wrong tool for the job.