in reply to Constant variables

Define it outside the unless loops as (maybe) my $errorcount = 0;