>>>>> "AB" == Alex Brelsfoard
>>>>> <alex.brelsfoard-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> writes:
>>> You should really be using a hash instead of symbolic references.
AB> Perhaps this is where the issue is.
AB> I am _trying_ to use a hash.
AB> Just a dynamically named one.
no. you are using symrefs. renaming it doesn't change what you are
doing. use a real hash. as i said before symrefs are just using the
symbol table for a hash. there is no benefit to doing that and plenty of
downside (which you are seeing now IMO).
AB> Here's what's happening:
AB> I read in a file with an unknown list of traits.
AB> With those traits is a list of people (identified by ID) and a score for
AB> each person for each trait they are tested on.
AB> As I read in the file I try to populate the hash array defined as
AB> such:
there is no such thing as a hash array. hashes or arrays. i assume you
mean hash.
AB> $arrayname = "fullTraitIndex_$trait";
AB> $arrayName{$personID} = $score;
that is just a basic hash of hashes. and there is no array there so that
is a poor name. the symbol table is a hash tree meant for munging
symbols. your data works perfectly fine with normal perl data trees.
AB> Meanwhile I keep track of the list of traits.
AB> Any suggestions as how to better accomplish this?
a regular hash of hashes is what you want. your problem needs a 2 level
hash tree which is something you may not have played with before. you
were trying to emulate one with symrefs but they are very easy to do
with hashes and hash refs.
read perllol and perldsc to learn about perl data trees. and perlreftut
and perlref for more on hash references.
uri
--
Uri Guttman ------ uri-X/06uaNR9nFmbZtjAW+qKA@xxxxxxxxxxxxxxxx --------
http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
|