One option is to use a module like Log::Log4Perl. You can set several levels of messages (debug, info, etc.) and only the ones at or above the current priority level (as defined at start time in a config file) will print. The output can be directed to standard error or a file, also.