The array I want to query does not change during execution:
my @const_arr=qw( a b c d e f g);
The input is a string containing the indices I want to access, for example:
my $str ="1,4";
Is there something (besides iterating over the indices in $str) along the lines of @subarray = @const_arr[$str] that will result in @subarray containing [b,e]
?
evalto parse your input is overkill, and opens the door to security issues.splitis a better tool for the job.my @const_arr=(a,b,c,d,e,f);