perlquestion
arunhorne
<p>Hi... I want to increment the value of a hash by one on a certain condition. I thought the following would work:</p>
<code>
$thes_name{$fields[1]} = thes_name{$fields[1]}++;
</code>
<p>However the value always remains as 1 (the value for each key is initialised to 1). The following code works though:</p>
<code>
$count = $thes_name{$fields[1]};
$count++;
$thes_name{$fields[1]} = $count;
</code>
<p>Can anyone tell me why this is... I would like to use the former code style if possible for compactness/to avoid creating another variable.</p>
<p>Thanks,</p>
____________<br>
<font color="#FF0000">A</font><font color="#FF8040">r</font><font color="#008000">u</font><font color="#0000A0">n</font>