http://qs321.pair.com?node_id=118975


in reply to Varying Variable Names

You can name variables with other variables, but it is strongly not reccommend. For why see this article. Instead, you should use an array of arrays, which is ultimately easier to manage. (update:) Or, depending upon what you need to do, you may find you need to, in this case, use a hash of arrays described in perldsc, along with many other possible data structures

Replies are listed 'Best First'.
Re: Re: Varying Variable Names
by willick (Novice) on Oct 16, 2001 at 00:56 UTC
    Even if it's strongly not recommended, I need to know how to do it. If I can just name my arrays @array1, @array2, etc it will be easier for what I'm doing.
      If the answer is "I need a variable-variable name", you almost certainly asked the wrong question. What question were you answering here? And what question was that a larger part of?

      -- Randal L. Schwartz, Perl hacker

      Convince us that you really need to do it (i.e. tell us a bit more about what you are doing) and we'll help you get it done. I have almost never seen an instance when @array1, @array2, etc. was the right thing to do, nor made things any easier.

      -Blake