Hi,
I'm trying to pass a hash into a subroutine a few times.
When I pass the hash in I use
$ref_to_wf=\%wordswithfreq;
then pass the $ref_to_wf to the subroutine.
In the subroutine I set the reference to $answerarray.
When I want to modify a value in the hash, say
$answerarray->{$temp}++;
It works fine, but when I want to add a new value in the hash it will add the value, but not what its equal to.
For example:
$temp="NewVal"
$answerarray{$temp}=1;
When the subroutine is called again it will see
$answerarray{"NewVal"} as being 0.
Can anyone tell me what I'm doing wrong?
Thanks
I'm trying to pass a hash into a subroutine a few times.
When I pass the hash in I use
$ref_to_wf=\%wordswithfreq;
then pass the $ref_to_wf to the subroutine.
In the subroutine I set the reference to $answerarray.
When I want to modify a value in the hash, say
$answerarray->{$temp}++;
It works fine, but when I want to add a new value in the hash it will add the value, but not what its equal to.
For example:
$temp="NewVal"
$answerarray{$temp}=1;
When the subroutine is called again it will see
$answerarray{"NewVal"} as being 0.
Can anyone tell me what I'm doing wrong?
Thanks