#!/usr/bin/perl use strict; use warnings; use feature qw{ state }; sub html { my ($text) = @_; # Make the header idempotent state $b_header++ or print "Content-type: text/html\n\n"; print $text; } html("
This is some html, prior to which a header is printed\n"); html("
This is too (but the header was printed already)\n"); #### Content-type: text/html
This is some html, prior to which a header is printed
This is too (but the header was printed already)