Oh! I completely read your original question wrong. At the expense of adding more programming logic to your script, couldn't you simply pass in a CGI parameter (as_email) and exclude certain portions of the HTML page if present? Here's is where tools such as HTML::Template and Template Toolkit are a big win:
use strict;
use warnings;
use CGI;
use HTML::Template;
my $cgi = CGI->new;
my $tmpl = HTML::Template->new(
filehandle => \*DATA,
associate => $cgi,
);
print $cgi->header, $tmpl->output;
__DATA__
<html>
<head>
<title>insert generic title</title>
</head>
<body>
<h1>Hello World.</h1>
<tmpl_unless as_email>
<p>This only appears when as_email is not present.</p>
</tmpl_unless>
</body>
</html>
Try calling this CGI script with the parameter as_email set to a true value.
|