HTML and HTTP headers are two different things, so it's a good idea to have them in separate functions. For lazy users, you can provide a wrapper third function which calls both:
sub print_everything_with_extra_cheese {
print header();
print printHTML();
}