I'm at my wit's end trying to figure out why this isn't working, and have visited many of the wonderfully instructive tutorials on references here intro to references and the great responses to similar questions from others, but i still can't seem to solve this! I realize that i must be confusing hashes for arrays somewhere, but it's not clear to me where?

i am reading records from a database (MS-Access, unfortunately) on a Win2000 server, where the records have responses from judges ($j_name) who have scored three elements($mentor, $ptcare,$clinres) of a nomination($n_name). I want to generate a report of all the scores submitted by each judge for multiple nominees, so an array in a hash of arrays seemed like the logical way to go. It works fine if i comment out line 52 (i get the expected hash of arrays, showing which nominees were judged by which judges), but when i add back line 52, I get the above error "Can't coerce array into hash....at line 52". i've also tried using the syntax: "$judge{$j_name}->{Nominee}->{Scores} = [$mentor,$ptcare,$clinres]; " with the same error. i'm sure i'm making some kind of dereferencing error, i just can't see it. TIA for your kind and patient help!

40 my %judge = (); 41 while ($db->FetchRow()) { 42 my $n_name = $db->Data("NOMNAME"); 43 my $mentor = $db->Data("MENTOR"); 44 my $ptcare = $db->Data("PTCARE"); 45 my $clinres = $db->Data("CLINRES"); 46 my $j_name = $db->Data("JUDGENAME"); 47 my $j_inst = $db->Data("JUDGEINST"); 48 print "<p>$j_name, $j_inst, $n_name</p>"; 49 $judge{$j_name} = {JudgeInst => $j_inst} 50 unless exists $judge{$j_name}; 51 push @{$judge{$j_name}->{Nominee}}, $n_name; 52 push @{$judge{$j_name}->{Nominee}->{Scores}}, + $mentor,$ptcare,$clinres; }

In reply to Can't coerce array into hash by jck

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.