|Pathologically Eclectic Rubbish Lister|
Re: Array loops and assignmentsby rjt (Deacon)
|on Jul 07, 2013 at 21:32 UTC||Need Help??|
The real problem I see is that if you really are referring to values by their index (regardless of how you accomplish that), that's probably a rather serious design problem. Then again, you say:
The requirement is that 8 elements of the array be stored in separate attributes. So instead of doing a single-assignment for each attribute, I was hoping to just put it in a loop and assign it to the corresponding variable.
That's actually quite a common requirement, most often seen in sub argument processing:
my ($name, $number) = @_;
For longer and/or variable lists of arguments, hashes provide more flexibility and basically a free namespace:
Update: Whoops, now I'm hungry.