I can't see the actual mistake, but here are some things you should always do and maybe that even fixes your problem:
Always use "use strict;"!! You might even want to use the "-w" tag.
Don't use global variables to pass data to subroutines. use something like that instead: &count ($cathegory);
Try to enter an "chomp ($zahl);" between reading it and the incement-operator
Maybe it helps for debuging to insert that line after "$zahl++;": if (!$zahl) { &fehler ('Counter is zero'); }
If that doesn't help at all review your flush/flock code. I never lock counter files and it always works fine, so I don't thinks it's neccessary..
Regards, octopus