Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
"be consistent"
 
PerlMonks  

Re:^5 another 'array to hash' question

by allolex (Curate)
on Dec 10, 2003 at 11:41 UTC ( [id://313768]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://313768]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.