Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Building data structure from multi-row/column tableby LanX (Saint) |
on Apr 03, 2015 at 03:55 UTC ( [id://1122325]=note: print w/replies, xml ) | Need Help?? |
I think you have to separate heads and data of a table. your current structure is problematic, because HoHs are unsorted and you can't distinguish what the row/column headers are
(untested) You need to look-up indices to get the data now. This could be encapsulated in a tied hash or an object class.¹ "Age Group" makes it a bit more complicated, not sure what it is, how would you call it? Maybe a "CATEGORY" field of the rows? I hope you get the point and this helps. :)
PS: pretty sure someone will come up with a CPAN² module now... :)
update¹) for instance you could bless the hash above into a class My::Table . Then $obj->rows returns a list of names, and $obj->entry("Male","0-9") returns the entry, and so on. ²) like Data::Table
In Section
Seekers of Perl Wisdom
|
|