This is strange.
I would be very inclined to believe that something fails before the resetCounters parameter is set, but then "strict" should prevent it.
Have you tried using ampersand?
&resetCounters();
[EDIT]
The only place I've seen something like this is CARP.
Something in the script does not compile, so the BEGIN operator does not compile, and you end up getting an error from it, and not from the code that failed.
use CGI::Carp qw(fatalsToBrowser set_message);
source share