1 | As in many interpreters, PERL allows you to generate a line from the interpreter using an eval function (JavaScript is similar) |
2 | Suppose you had two arrays $fred[$index] and $jim[$index] and you wanted to load them given value of $index and an ascii string $name (which could have been read in) taking value 'fred' or 'jim'. This can be achieved by: |
3 | eval('$' . $name . '[' . $index . ']') = $value; |
4 | eval returns result of evaluating(executing) argument as PERL script and continues |
5 | In this case, you can achieve the same results with indexed associative arrays: |
6 | $options[$index]{$name} = $value; |
7 | using the nultidimensional array notation introduced in PERL5 |