$id == $FOO && ($tfoo += $amt) && last SWITCH; depends on the final value of $tfoo being non-zero. If zero, the switct falls through to the default and awards double credit :)
To repair, have 'last' execute unconditionally with the comma operator: $id == $FOO && ($tfoo += $amt), last SWITCH;
Snippets of code should be wrapped in
<code> tags not<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).