in reply to Can't coerce array into hash

OK, I think I can tell you what your problem is, it's an easy mistake to make as hashes can be so confusing sometimes.

Basically, after line 51 you have an single entry array [$n-name] in:

$judge{$j_name}->{Nominee}
Which is fine, but this means, if you call:
$judge{$j_name}->{Nominee}
you get [$n-name]. And you MAKE that call, in line 52, when you say:
$judge{$j_name}->{Nominee}->{Scores}
So you're turning around and saying that [$n-name] is also %Scores. Hence the error.

Solution:

51 push @{$judge{$j_name}->{Nominee}->{$n_name}->{Scores}}, $mentor,$ptcare,$clinres;

OR

51 push @{$judge{$j_name}->{Nominee}->{$n_name}}, $mentor,$ptcare,$clinres;

Hope I got that right.

Cheers
Sam

Replies are listed 'Best First'.
Re: Re: Can't coerce array into hash
by Anonymous Monk on Sep 24, 2003 at 17:37 UTC
    Thanks so much for the quick replies!!! both solutions worked, although i don't really need the extra "Scores" key that is generated by the first solution.

    Another solution is:

    push @{$judge{$j_name}->{Nominee}},$n_name => [$mentor,$ptcare,$clinre +s];

    Thanks again!