in reply to Question with Dynamically Creating arrays.

you are quite correct in your assessment of the hardcoded array name code needing some re-factoring, for extensibility pursposes. i'd only consider someone stupid-actually usually just lazy-if you point out to them such a design shortcoming, and they won't bother to fix or even bother to learn. so you shouldn't be so harsh on yourself.
other monks have pointed to solutions and possible further refactoring. it just dawned on me that some of these solutions might be a little hard to wrap one's head around sometimes. the straightforward solution is to go from @aa, @bb, @cc to $arrays{aa}, $arrays{bb}, $arrays{cc} etc. thus merely adding a hash wrapper.
the hardest line to type correctly is: stty erase ^H
  • Comment on Re: Question with Dynamically Creating arrays.

Replies are listed 'Best First'.
Re^2: Question with Dynamically Creating arrays.
by abhijithtk (Novice) on Jul 22, 2010 at 15:34 UTC
    Hello Everyone

    Thanks for all the replies. It was really useful and now I got it to work, although im yet to modify other portions of my code, which i am doing right now.
    @aquarium - what u mentioned is pretty much what i had done.
    %struct;
    i use the $key and create a hash value which i then make it point to an array. By doing this i have my structure unique to the key. something like :
    push(@{$struct{$key}},"value") or // i passed the reference n added the values to the array add(\@{$struct{$key}});
    So now $struct points to an array, and also has the key as i wanted.
    Thanks for the help everyone!