in reply to Re: Re: Re: Re: another 'array to hash' question
in thread another 'array to hash' question
I really don't see why you shouldn't do it the way you have it coded here.because, one, I might not know what the variable names are (they may be variables... as alluded to below), and two, it just gets tiring typing out a hash structure especially if a lot of fields are involved. Tom's suggestion below works well for such a problem.
Why are the variable names important if you know what each column represents? A hash structure is indeed useful for HTML::Template so you can refer to that data by name in the template, which is, for most people's purposes, completely separate from the code. (In templates there is no guarantee that the person editing the template will know anything about structures in the code.) But with the AofA, you know that $crazypersonarray->[0] is a lastname *variable* and so on. You could even assign $ln = 0 and refer to it as $crazypersonarray->[$ln]. Your array of hashes can be accessed using something like print $hash->{ln} for my $hash ( @aoh );. That said, I think you should use what feels intuitively "right". :)
--
Allolex
|
---|