logo       

Re: [Boston.pm] Odd printing problem: msg#00044

Subject: Re: [Boston.pm] Odd printing problem
>>>>> "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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe