in reply to Apache Modules

The code outside your handler ( my $query = new CGI()) will get executed at server startup. Only code inside your handler gets executed on each request. Try moving that line inside your handler and see what happens.