in reply to Pop quiz: find the bug

$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;

After Compline,
Zaxo