in reply to Array named for array element?

You can do that with symbolic references:
no strict 'refs'; @{"$array[0]"} = (1, 2, 3, 4);

Having said that, why would you want to do that? In most programming languages, you can't do that, and people don't even ask how to do that. In Perl, it's not at all necessary, it's potentially dangerous, and considered bad programming style. Now that I've told you how to do it, answer my question: Why would you want to do this?

Abigail

Replies are listed 'Best First'.
Re: Re: Array named for array element?
by Anonymous Monk on Jul 02, 2003 at 21:23 UTC
    The reason I want to do it this way is because the script I'm writing is to be used for files of varied length with differing frequencies of the first element occurring in the text. And the first element will vary between different files. I'm thinking this might be best done with an array of arrays, where the array is named for the first element, and the arrays underneath would have the rest of the data.

      Then you definitely want a hash of arrays just like everyone else suggested. :)

      --
      Allolex

        What happens when that has has repeated keys though?