in reply to mod_perl v2

If printing is your only problem, you can dispense with referring to $r:
sub printContent { print $_[0]; # works in CGI and mod_perl environments }